It is currently Thu Jul 19, 2018 10:48 am

 All times are UTC - 7 hours

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Sound 4 (Noise): Highest frequencies?Posted: Sun Jan 26, 2014 10:13 am

Joined: Sun Jan 26, 2014 9:31 am
Posts: 289
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.

Top

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Sun Jan 26, 2014 10:16 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20270
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

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Sun Jan 26, 2014 10:24 am

Joined: Sun Jan 26, 2014 9:31 am
Posts: 289
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

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Sun Jan 26, 2014 2:02 pm
 Formerly ~J-@D!~

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

_________________
((λ (x) (x x)) (λ (x) (x x)))

Top

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Wed Feb 12, 2014 11:15 pm

Joined: Sun Jan 26, 2014 9:31 am
Posts: 289
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

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Thu Feb 13, 2014 11:13 am

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1249
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

Top

 Post subject: Re: Sound 4 (Noise): Highest frequencies?Posted: Thu Feb 13, 2014 7:30 pm

Joined: Sun Jan 26, 2014 9:31 am
Posts: 289
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

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 3 guests

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki