5

The Nintendo DS hardware has 16 audio channels that support 16-bit audio (PCM16) at a sample rate of 32,768 Hz. However, the mixer limits the output to 10 bits (-200h to 1FFh). From GBATEK:

When configured to max volume (and left-most or right-most panning), each channel can span the full 10bit output range (-200h..1FFh) on one speaker, as well as the full 16bit input range (-8000h..7FFFh) on one capture unit.

The document goes on to explain that this is done by the mixer applying the master volume biases:

After applying the master volume, the signed left/right audio signals are in range -200h..+1FFh

[...]

sampling frequency after mixing with PWM modulation is 32.768 kHz with an amplitude resolution of 10 bits.

The memory register at 4000500h has a bit which can disable the master volume:

4000500h - NDS7 - SOUNDCNT - Sound Control Register (R/W)

  Bit0-6   Master Volume       (0..127=silent..loud)
  Bit7     Not used            (always zero)
  Bit8-9   Left Output from    (0=Left Mixer, 1=Ch1, 2=Ch3, 3=Ch1+Ch3)
  Bit10-11 Right Output from   (0=Right Mixer, 1=Ch1, 2=Ch3, 3=Ch1+Ch3)
  Bit12    Output Ch1 to Mixer (0=Yes, 1=No) (both Left/Right)
  Bit13    Output Ch3 to Mixer (0=Yes, 1=No) (both Left/Right)
  Bit14    Not used            (always zero)
  Bit15    Master Enable       (0=Disable, 1=Enable)
  Bit16-31 Not used            (always zero)

Is it possible to utilize bit 15 (Master Enable) to get around this limitation?
If not, is there any other way?

Note that the bit-widths at each step of the mixing are described in the following table, and the above description makes me wonder if the clipping step can be skipped by disabling Master Enable:

Channel/Mixer Bit-Widths

  Step                           Bits  Min        Max
  0 Incoming PCM16 Data          16.0  -8000h     +7FFFh
  1 Volume Divider (div 1..16)   16.4  -8000h     +7FFFh
  2 Volume Factor (mul N/128)    16.11 -8000h     +7FFFh
  3 Panning (mul N/128)          16.18 -8000h     +7FFFh
  4 Rounding Down (strip 10bit)  16.8  -8000h     +7FFFh
  5 Mixer (add channel 0..15)    20.8  -80000h    +7FFF0h
  6 Master Volume (mul N/128/64) 14.21 -2000h     +1FF0h
  7 Strip fraction               14.0  -2000h     +1FF0h
  8 Add Bias (0..3FFh, def=200h) 15.0  -2000h+0   +1FF0h+3FFh
  9 Clip (min/max 0h..3FFh)      10.0  0          +3FFh

I'm aware that the DSi does full 16-bit PCM at 48 kHz, but I'm interested in the models that lacked overkill sound hardware.

4
  • AFAICT there is no way to get more. reducing PCM depth is a good way so save on DA converters. Also, while the idea is interesting for the sake of it, I doubt that the DS (or DSi) hardware (speaker, etc) is in any way adequate to take advantage of 10 bit - even less 16. Or in simpler words, 10 bit might be already overkill for its cheap speakers and noisy plastic enclosure.
    – Raffzahn
    Aug 5, 2022 at 9:03
  • @Raffzahn I'm aware that the speaker drivers won't really benefit from full 16-bit resolution (although it did support head phones which could be higher quality). I'm just curious for the sake of it.
    – forest
    Aug 5, 2022 at 20:20
  • No Prob, I fully understand that desire :)) I think Justme is rather on spot with his answer.
    – Raffzahn
    Aug 5, 2022 at 22:44
  • 1
    @Raffzahn He is. The only reason I'm not accepting it right away is because I like to give a little time to see if others post answers, perhaps with even more detail (e.g. evidence that the PWM modulator clock can't be increased, although it's certainly a reasonable assumption that it cannot).
    – forest
    Aug 5, 2022 at 23:01

1 Answer 1

3

The document you link to basically describes that the DS audio DAC is just a 10-bit PWM modulator.

So it's not the mixer that is the limitation, it is the DAC that can just take 10 bits in.

Because it's a PWM DAC, actually the DAC output is only 1-bit, but it can output pulses with length described with 10-bit counter, allowing for 1024 different pulse lengths, and it can output these pulses at a rate of 32768 Hz as that is described as the sampling rate. Which means the PWM counter works at about 33.6 MHz and it should match the clock frequency at which the audio subsystem runs at. These 1-bit pulses are then low-pass filtered and that's basically the audio sent to headphones.

Since it has a 10-bit PWM DAC and it has no means of modifying the DAC parameters, the output is limited to 10-bit resolution and 32768 Hz rate.

If it was possible to modify the parameters, increasing the bit depth by one bit would halve the sampling rate, unless the PWM modulator clock can be set to a higher frequency.

1
  • This is what I had thought, but I wondered if there was any trick to get around it. I guess not.
    – forest
    Aug 5, 2022 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .