It is currently Mon Nov 20, 2017 6:51 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Mon Jun 27, 2016 9:54 pm 
Offline
Formerly ~J-@D!~
User avatar

Joined: Sun Mar 12, 2006 12:36 am
Posts: 445
Location: Rive nord de Montréal
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.


Top
 Profile  
 
PostPosted: Thu Jul 07, 2016 2:48 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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 47 times
Top
 Profile  
 
PostPosted: Thu Jul 07, 2016 2:54 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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 1124 times ]
Top
 Profile  
 
PostPosted: Thu Jul 07, 2016 7:20 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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.


Top
 Profile  
 
PostPosted: Thu Jul 07, 2016 7:48 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 3:57 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
Battletoads uses $4011 for raw dmc, so how's unrelated?
On channel update, I do (value&$7F) << 8. The value is never zero.


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 10:43 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
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 1049 times ]

Why is this here?

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


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 12:58 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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.


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 1:11 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
Given prior guesses: try bypassing your resampler? (Just dump the 1.8MHz audio file to disk)


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 1:32 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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.


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 2:27 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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
Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 4:45 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
Yup, it's your resampler.

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


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 5:32 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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?


Top
 Profile  
 
PostPosted: Fri Jul 08, 2016 6:09 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
Top: 1.8MHz, perfectly clean.
Bottom: 48kHz, bonus noise.


Attachments:
compare-sample-rates.png
compare-sample-rates.png [ 22.38 KiB | Viewed 998 times ]
Top
 Profile  
 
PostPosted: Sat Jul 09, 2016 5:21 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group