nesdev.com
http://forums.nesdev.com/

DMC unsigned samples?
http://forums.nesdev.com/viewtopic.php?f=3&t=14455
Page 2 of 3

Author:  Jarhmander [ Mon Jun 27, 2016 9:54 pm ]
Post subject:  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.

Author:  Zepper [ Thu Jul 07, 2016 2:48 pm ]
Post subject:  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.

Attachments:
Battletoads_wav.zip [246.09 KiB]
Downloaded 43 times

Author:  rainwarrior [ Thu Jul 07, 2016 2:54 pm ]
Post subject:  Re: DMC unsigned samples?

Zepper wrote:
It worked like a charm. Just listen the file.

The high frequency whine is still there. Look at the silent section at the start of this recording; why isn't it actually silent?

Attachments:
battletoads_whine.png
battletoads_whine.png [ 56.78 KiB | Viewed 1067 times ]

Author:  Zepper [ Thu Jul 07, 2016 7:20 pm ]
Post subject:  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.

Author:  rainwarrior [ Thu Jul 07, 2016 7:48 pm ]
Post subject:  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.

Author:  Zepper [ Fri Jul 08, 2016 3:57 am ]
Post subject:  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.

Author:  lidnariq [ Fri Jul 08, 2016 10:43 am ]
Post subject:  Re: DMC unsigned samples?

Look at your file. Look at the very beginning, before DMC is playing.
Attachment:
Battletoads (U) 000.png
Battletoads (U) 000.png [ 3.75 KiB | Viewed 992 times ]

Why is this here?

It is not DMC. It is a bug somewhere in your emulator.

Author:  Zepper [ Fri Jul 08, 2016 12:58 pm ]
Post subject:  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:
Code:
* 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**


In each apu update:
Code:
decay_master = 13125;
decay_value = 352;

decay_master -= decay_value;
if(decay_master <= 0)
//calculate the sample and send it to the wavebuffer.


APU source code may be avaliable if you're willing for it.

Author:  lidnariq [ Fri Jul 08, 2016 1:11 pm ]
Post subject:  Re: DMC unsigned samples?

Given prior guesses: try bypassing your resampler? (Just dump the 1.8MHz audio file to disk)

Author:  koitsu [ Fri Jul 08, 2016 1:32 pm ]
Post subject:  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.

Author:  Zepper [ Fri Jul 08, 2016 2:27 pm ]
Post subject:  Re: DMC unsigned samples?

lidnariq wrote:
Given prior guesses: try bypassing your resampler? (Just dump the 1.8MHz audio file to disk)

Fine. :beer:
Here's the raw dump, 16-bit sample, low byte first.

Attachments:
nes_raw.zip [90.83 KiB]
Downloaded 43 times

Author:  lidnariq [ Fri Jul 08, 2016 4:45 pm ]
Post subject:  Re: DMC unsigned samples?

Yup, it's your resampler.

The raw 1.8MHz sample rate output here is perfectly clean.

Author:  Zepper [ Fri Jul 08, 2016 5:32 pm ]
Post subject:  Re: DMC unsigned samples?

lidnariq wrote:
Yup, it's your resampler.

The raw 1.8MHz sample rate output here is perfectly clean.


I didn't get it. :? :? How so? What's exactly the difference between the waves?
Care to take screenshots of the waveforms for comparison, plz?

Author:  lidnariq [ Fri Jul 08, 2016 6:09 pm ]
Post subject:  Re: DMC unsigned samples?

Top: 1.8MHz, perfectly clean.
Bottom: 48kHz, bonus noise.

Attachments:
compare-sample-rates.png
compare-sample-rates.png [ 22.38 KiB | Viewed 941 times ]

Author:  Zepper [ Sat Jul 09, 2016 5:21 am ]
Post subject:  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...
Code:
       |-------|    |-------|
       |       |    |       |
       |       |____|       |____ (silence,
       |                        but not zero)
       |
       | attack
_______

begin
(silence = 0)


There's a noise in the waveform, yeah, I had seen it.

Page 2 of 3 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/