It is currently Fri Oct 20, 2017 6:22 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Jan 26, 2014 10:13 am 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
For some reason, I'm finding the GB's Noise Channel (Sound 4) the most troublesome to fully understand. I'm trying to wrap my head around how it works, but I still have a couple of major questions.

1) Is the highest frequency for Sound 4's programmable frequency timer really 524288Hz? For example, assuming I set NR43 to 0x00 (using a 15 stage LSFR for simplicity), am I correct in saying that this will produce a frequency timer of 524288Hz?

The documents I've read say that the Sound 4's period is decided by the Dividing Ratio (Bits 0 - 2 of NR43) shifted some number of bits to left: (http://gbdev.gg8.se/wiki/articles/Gameb ... se_Channel). This should mean than when NR43 = 0x00, Sound 4's period is 8 clocks, meaning the frequency is 524288Hz.

Just to be sure, this formula decides how often the APU should generate a waveform, right?


2) Is the highest frequency of the LSFR counter also 524288Hz? If not what is the correct formula for determining this?


3) If the maximum frequency timer is 524288Hz, how do emulators reasonably recreate the noise effect using only 44100Hz? For example, I wrote a small test ROM to continuously output sound on Sound 4 with NR43 set to 0x00, and I tested it both on VBA-M as well as my old Game Boy Color. As far as my ears could tell, they were both very similar if not identical for all intents and purposes. This is the most frustrating part I'm trying to understand. I've included the test ROM as an attachment for reference (should play on any emulator and real hardware).


Sorry if this has been discussed before, but I've read through a couple of documents already (GBSOUND.txt, game_sound_emulation_by_blargg.txt, the GBDev Wiki, even the docs from belogic.com about GBA's sound) but I'm still not sure I'm getting the whole frequency part right. Any help is greatly appreciated.


Attachments:
NOI_Normal.gb [32 KiB]
Downloaded 83 times
Top
 Profile  
 
PostPosted: Sun Jan 26, 2014 10:16 am 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19110
Location: NE Indiana, USA (NTSC)
Shonumi wrote:
3) If the maximum frequency timer is 524288Hz, how do emulators reasonably recreate the noise effect using only 44100Hz?

The same way you display a 6000-pixel wide photo on a 1920-pixel-wide monitor: blur it and decimate it. Emulators use some sort of low-pass filter or band-limited synthesis method to average out samples and remove frequencies too high to hear.


Top
 Profile  
 
PostPosted: Sun Jan 26, 2014 10:24 am 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
Thanks tepples. See, I've dealt with images and pixels for years, but I literally just started getting to grips with sound programming months ago (no joke, had no idea what frequencies and periods really meant until October :p). I'll definitely have a look at both methods.


Top
 Profile  
 
PostPosted: Sun Jan 26, 2014 2:02 pm 
Offline
Formerly ~J-@D!~
User avatar

Joined: Sun Mar 12, 2006 12:36 am
Posts: 445
Location: Rive nord de Montréal
Tip: look for Sample Rate Conversion on the Interwebz.


Top
 Profile  
 
PostPosted: Wed Feb 12, 2014 11:15 pm 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
Thanks for all of the replies everyone, I really appreciate your advice and taking the time to help me.

I'm still very confused about how the Game Boy Sound 4 actually determines the noise channel output frequency and the frequency at which it runs the LSFR as a Psuedo-Random Number Generator. I'm actually at my wits ends trying to figure this out. I'm primarily going off of http://www.devrs.com/gb/files/hosted/GBSOUND.txt, but honestly it's as clear as mud to me.

Basically, the Game Boy uses NR43 (0xFF22) to control how fast to run the noise channel and the LSFR. It uses these bits to determine something called the Dividing Ratio and a Shift Clock frequency. What I need to know is:

1) Using NR43 (0xFF22) what is the formula that determines Sound 4's output frequency?

2) Using NR43 (0xFF22) what is the formula that determines Sound 4's LSFR frequency (how many times per-second to run it's psuedo-random number generator)?

GBSOUND.txt claims that Sound 4 can output frequencies from 2Hz to 1048576Hz, but this isn't very clearly stated how one arrives at those numbers. I've noted the formulas present in that document, but every time I try to do the math myself, it never seems to work out. I just can't figure out any of it. Perhaps I'm just dense, in which case I'd be eternally grateful if someone could step through the math in a clear and exact manner (one example is fine).


Top
 Profile  
 
PostPosted: Thu Feb 13, 2014 11:13 am 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
According to pandocs,
Quote:
FF22 - NR43 - Channel 4 Polynomial Counter (R/W)
[...]
Bit 7-4 - Shift Clock Frequency (s)
Bit 3 - Counter Step/Width (0=15 bits, 1=7 bits)
Bit 2-0 - Dividing Ratio of Frequencies (r)

Frequency = 524288 Hz / r / 2^(s+1) ;For r=0 assume r=0.5 instead


This one equation should answer both of your questions.


Top
 Profile  
 
PostPosted: Thu Feb 13, 2014 7:30 pm 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
Drag wrote:
According to pandocs,
Quote:
FF22 - NR43 - Channel 4 Polynomial Counter (R/W)
[...]
Bit 7-4 - Shift Clock Frequency (s)
Bit 3 - Counter Step/Width (0=15 bits, 1=7 bits)
Bit 2-0 - Dividing Ratio of Frequencies (r)

Frequency = 524288 Hz / r / 2^(s+1) ;For r=0 assume r=0.5 instead


This one equation should answer both of your questions.


Thanks man, I'm a complete idiot. For some reason I can't count, and I kept taking only the top three bits of NR43 instead of the top nibble. A week's worth of frustration because I kept shifting and masking by 0x7 not 0xF :(

Anyway, many thanks to everyone, you've all been great :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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