DMC unsigned samples?
Moderator: Moderators
- Jarhmander
- Formerly ~J-@D!~
- Posts: 570
- Joined: Sun Mar 12, 2006 12:36 am
- Location: Rive nord de Montréal
Re: DMC unsigned samples?
The noise can come from an incorrect window function selected for the interpolation. I don't recommend using any window function that both ends are not zero (e.g. Hamming), I had a problem similar to yours in a toy resampler I made, a DC bias made some noise, and the noise would get bigger if the bias was increased.
((λ (x) (x x)) (λ (x) (x x)))
Re: DMC unsigned samples?
Found the problem. The output volume was coming directly from $4011 writes! Instead, it should come from channel update. In raw mode ($4011 samples only, no DPCM unit), the frequency reload should be 1 (cycle), instead of taking the first entry from the DMC frequencies table, or 0x1AC (NTSC).
It worked like a charm. Just listen the file.
It worked like a charm. Just listen the file.
- Attachments
-
- Battletoads_wav.zip
- (246.09 KiB) Downloaded 176 times
- rainwarrior
- Posts: 8756
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: DMC unsigned samples?
The high frequency whine is still there. Look at the silent section at the start of this recording; why isn't it actually silent?Zepper wrote:It worked like a charm. Just listen the file.
Re: DMC unsigned samples?
Because the value written to $4011 is never zero. In unsigned samples mode, the value written to $4011 is the volume level output to dac. In short words, there isn't any kind of sample filtering. If you don't believe me, just log the values written to $4011.
- rainwarrior
- Posts: 8756
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: DMC unsigned samples?
I'm not asking why it's not 0, I'm asking why it's not flat (flat = silent). There is a high frequency whine there instead of silence, which you asked about in the very first post in this thread.
This doesn't have anything to do with $4011, it's a problem with your sound generation in general. Maybe with downsampling, as has been suggested, or maybe something else.
This doesn't have anything to do with $4011, it's a problem with your sound generation in general. Maybe with downsampling, as has been suggested, or maybe something else.
Re: DMC unsigned samples?
Battletoads uses $4011 for raw dmc, so how's unrelated?
On channel update, I do (value&$7F) << 8. The value is never zero.
On channel update, I do (value&$7F) << 8. The value is never zero.
Re: DMC unsigned samples?
Look at your file. Look at the very beginning, before DMC is playing.
It is not DMC. It is a bug somewhere in your emulator.
Why is this here?It is not DMC. It is a bug somewhere in your emulator.
Re: DMC unsigned samples?
I use GoldWave to view the waveform... and yeah, I know of this problem. But I have no clue what's up.
As I showed up... it's the $4011 value & $7F << 8 (16-bit sample). The value written is never zero.
I have two methods of resampling, but both sum (+) the current sample to an adder. One counts the N number of added samples and divide the adder by N; another do the same, but instead of using a division by N, I shift right the adder. Better results are with adder >> 5.
This is my resample value based on the NES master clock:
In each apu update:
APU source code may be avaliable if you're willing for it.
As I showed up... it's the $4011 value & $7F << 8 (16-bit sample). The value written is never zero.
I have two methods of resampling, but both sum (+) the current sample to an adder. One counts the N number of added samples and divide the adder by N; another do the same, but instead of using a division by N, I shift right the adder. Better results are with adder >> 5.
This is my resample value based on the NES master clock:
Code: Select all
* The exact sample rate of the NES audio DAC itself is 39375000/22 Hz = 1.7898 MHz.
resample:
(39375000 / 22) / 48000Hz (PC rate) =
= 39375000 / 48000*22 (both x22) =
= 393750 / 480*22 (both DIV 100) =
= 393750 / 10560 =
= 39375 / 1056 (both DIV 10) = ~37 samples per sync.
both DIV 3 => **13125 / 352**
Code: Select all
decay_master = 13125;
decay_value = 352;
decay_master -= decay_value;
if(decay_master <= 0)
//calculate the sample and send it to the wavebuffer.
Re: DMC unsigned samples?
Given prior guesses: try bypassing your resampler? (Just dump the 1.8MHz audio file to disk)
Re: DMC unsigned samples?
I wouldn't be surprised if this turned out to be "some weird Allegro thing", somehow. I believe the version of Allegro being used here is 4.4, while 5.2 is the latest (edit: 5.2 appears to be latest, but I did find some prebuilt binaries that are labelled 5.3.0...). Not sure what type of audio layer is being used (DirectX/DirectSound I'd guess). The changelog for 5.0.0 to 5.0.1 has an entry that says "Play silence where needed in DirectSound driver", which made me chuckle.
Re: DMC unsigned samples?
Fine.lidnariq wrote:Given prior guesses: try bypassing your resampler? (Just dump the 1.8MHz audio file to disk)
Here's the raw dump, 16-bit sample, low byte first.
- Attachments
-
- nes_raw.zip
- (90.83 KiB) Downloaded 171 times
Re: DMC unsigned samples?
Yup, it's your resampler.
The raw 1.8MHz sample rate output here is perfectly clean.
The raw 1.8MHz sample rate output here is perfectly clean.
Re: DMC unsigned samples?
I didn't get it. How so? What's exactly the difference between the waves?lidnariq wrote:Yup, it's your resampler.
The raw 1.8MHz sample rate output here is perfectly clean.
Care to take screenshots of the waveforms for comparison, plz?
Re: DMC unsigned samples?
Hmm... I see. And I have to apologize for the language barrier.
Yes. I though we were talking about the DMC waveform not being centered and without silence when it should be.
Like...
There's a noise in the waveform, yeah, I had seen it.
Yes. I though we were talking about the DMC waveform not being centered and without silence when it should be.
Like...
Code: Select all
|-------| |-------|
| | | |
| |____| |____ (silence,
| but not zero)
|
| attack
_______
begin
(silence = 0)