DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Discussion of programming and development for the original Game Boy and Game Boy Color.
Dr.Wily
Posts: 11
Joined: Thu Feb 02, 2012 7:05 am
Location: Skull Castle
Contact:

DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dr.Wily »

Simples questions :

How works the DMG APU on Nintendo DS when a GBA game is used ?
Is there a real Gameboy hardware APU in Nintendo DS or it's just emulation ?
In DS mode, is DS games can use Gameboy channels ? (2 pulses, 1 wave, 1 noise)
User avatar
Bregalad
Posts: 8055
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Bregalad »

I always wondered that as well. I know the DS' sound channels have an option to generate square waves or white noise without requiring samples, but my understanding is that this mode is sparsely used by DS games. I don't know whether this was used to support GB(C)'s sound backwards compatibility or not. In all cases, compatibility seems complete and I've yet to see games which sounds any different on a DS than on a GBA (the same cannot be said about GBA emulators...) I could be wrong, though.
Dr.Wily
Posts: 11
Joined: Thu Feb 02, 2012 7:05 am
Location: Skull Castle
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dr.Wily »

I know the DS' sound channels have an option to generate square waves or white noise without requiring samples
Yes, DS' channels 8-13 generate some "PSG" like sounds. Channels 14-15 can generate white noise. But the DMG APU has specifics features like the wave channel who use a builtin wave patern memory of 16 bytes and a noise channel who use LSFR. These features are very specific to the Gameboy APU, especially the wave channel where the sounding depend of the revision of the CPU. I don't know if it's possible to emulate these features on DS.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by tepples »

I think those are available only while GBA mode is active, just as 2bpp 160x144 video is available only in GBC mode on a GBA.
Dr.Wily
Posts: 11
Joined: Thu Feb 02, 2012 7:05 am
Location: Skull Castle
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dr.Wily »

I think those are available only while GBA mode is active, just as 2bpp 160x144 video is available only in GBC mode on a GBA.
Thanks tepples. But the gameboy APU in DS is hardware or software ?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by tepples »

I'd guess hardware. But given that the PlayStation 2 emulates the original's GTE+GPU partially in software, I can't say for sure. To be 100 percent sure would require fuming nitric acid and microphotography.

Let's take a step back and talk about the goal you're seeking. Are you looking for behavior differences between GBC tone generators on a GBA in GBA mode and GBC tone generators on a DS in GBA mode?
Dr.Wily
Posts: 11
Joined: Thu Feb 02, 2012 7:05 am
Location: Skull Castle
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dr.Wily »

Are you looking for behavior differences between GBC tone generators on a GBA in GBA mode and GBC tone generators on a DS in GBA mode?
None of them. My purpose is to know how DS produces Gameboy sound, if this machine is reliable for compose music with orriginal Gameboy feeling.
All Gameboy models handle sound differently (especialy channel 3). I need to know if the orriginal tone generator circuitery in the Gameboy is the same as one present (or not) in DS.
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dwedit »

Supposedly, the DS mixes sound at 1,048,576Hz 24-bit, then cuts that down to 32768Hz 10-bit with PWM. But I've found that PSG sounds really bad on the DS, it sounds very aliased. So you'd get better sound with a software mixer that synthesizes sound at 32768Hz.
If it's mixing 16 channels at ~1MHz, it's probably playing all 16 sound channels in series for left and right channels, then downsampling with PWM. It wouldn't be playing PSG sound at anything faster than 32768Hz.

There is a GBA sound chip in there too, but it's completely inaccessible in DS mode.

I bet they kept PSG sound in there (DS MODE) just for the Pokemon cries.
Last edited by Dwedit on Thu Mar 02, 2017 10:24 am, edited 2 times in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by tepples »

Dwedit wrote:I bet they kept PSG sound in there just for the Pokemon cries.
That plus Nintendo knew how much CPU and programmer time was associated with software mixing. Some games (such as Doom and Pinobee) use the GBC channels for music and the GBA channels for PCM sound streamed directly from ROM rather than mixed in RAM, and even games with a software mixer (such as Mario Kart Super Circuit) run some instruments on the PSG.
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dwedit »

Was actually talking about DS mode there, not GBA mode, sorry if I wasn't clear enough. But the pokemon cries are still the same in DS games as they were in the GBC games.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by lidnariq »

Dwedit wrote:But I've found that PSG sounds really bad on the DS, it sounds very aliased.
Nocash's description of how the PSG is mixed into the audio on the GBA seems like it would also produce horrible aliasing...
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dwedit »

On a GBA you can request a PWM update rate of 131,072Hz with 7-bit audio, or even 262,144Hz with 6-bit audio. You can't do that on a DS.
I guess someone could try to figure out the quantization noise you'd get with aliased sampling at 131072Hz, but it's a lot less than the artifacts you'd get at 32768Hz.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Bregalad
Posts: 8055
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Bregalad »

Dwedit wrote:On a GBA you can request a PWM update rate of 131,072Hz with 7-bit audio, or even 262,144Hz with 6-bit audio. You can't do that on a DS.
I am not 100% sure, but I guess you can in GBA mode / i.e. a DS in GBA mode behaves like a geniune GBA in this regard.
Dr.Wily
Posts: 11
Joined: Thu Feb 02, 2012 7:05 am
Location: Skull Castle
Contact:

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Dr.Wily »

tepples wrote: Some games (such as Doom and Pinobee) use the GBC channels for music and the GBA channels for PCM sound
Many GBA games use pulse channels. On top of my head I think at Harmony of Dissonance, Kururin, Gradius Gen, Bubble Bobble - Old & New , Advance War, Contra Advance, Final Fantasy IV Advance and as you said Mario Kart.
This is not few games and the DS handles pretty well these channels. But how ?
I know that the 8080 is built in GBA SOC. But the DMG part has been removed in the DS, Nintendo would have left only the Gameboy sound circuitery ?
Dwedit wrote: But I've found that PSG sounds really bad on the DS, it sounds very aliased.
Yes, pulse channels seems more roughness than genuine Gameboy sound (include the GBA). That's why I wonder if the Gameboy channels are hardware or software on Nintendo DS.

EDIT : maybe you can move this post in GBDev section...
Shonumi
Posts: 342
Joined: Sun Jan 26, 2014 9:31 am

Re: DMG / CGB Gameboy sound on Nintendo DS - how it works ?

Post by Shonumi »

Dr. Wily wrote: This is not few games and the DS handles pretty well these channels. But how ?
Hasn't this been answered already? As far as we know, when the NDS switches to GBA mode, it just uses the GBA sound chip. The NDS has a lot of hardware bits inside it for handling GBA compatibility.
Dr. Wily wrote: I know that the 8080 is built in GBA SOC. But the DMG part has been removed in the DS, Nintendo would have left only the Gameboy sound circuitery ?
There's no need for the old DMG sound hardware because the GBA sound hardware is almost functionally identical for the PSG channels. Obviously there are some differences in the wave channel (e.g. you can have 64 samples instead of 32), but that's optional. Unless you're into chip tunes (in which case, almost every Game Boy model produces slightly different quality sound) the GBA can mimic DMG sound. And by that extension, the NDS can mimic DMG sound if you're playing in GBA mode.

I wouldn't say that the NDS (in GBA mode) can exactly, 100% recreate the waveforms you'd get from an original DMG, but it should be close enough if you're not very selective. But if you plan to use an NDS in GBA mode, you might as well just use a GBA instead.
Post Reply