DSP Memory Region

DSP Memory Region

Note that everything below may vary depending on the exact DSP firmware used and different variants have slightly different behaviours.

The DSP communicates with the application through two shared memory areas 0x8000 bytes long each (at 0x1FF50000 and 0x1FF70000 respectively). The DSP alternates between the use of these two areas (much like a double-buffer). Each area has 15 structures within it. The location of these structures can be obtained by reading channel 2 of the DSP pipe. A list of structures in the order the DSP addresses are read from the pipe follows:

1. Frame count

2. Input configurations

3. Input status

4. Input ADPCM coefficients

5. DSP configuration

6. DSP status

7. Output samples

8. Intermediate mix samples

9. Compressor table

10. DSP debug statistics

11. Unknown Coefficients

12. Unknown Coefficients

13. Unknown Coefficients

14. Surround sound biquad filter 1

15. Surround sound biquad filter 2

The DSP has 24 inputs, each of which are individually configurable. These 24 inputs each produce three sets of 4 audio channels (two left, two right).

These four audio channels feed into three intermediate mixers. Two of these intermediate mixers are used for effects and aux.

Frame Count #

The frame count of the first region must be even and the frame count of the second region must be odd.

The frame with the higher count is the “current region”.

The DSP firmware only responds if the first frame count is 4.

Input Config #

A 192 byte long structure. There are 24 of them.

OffsetTypeDescription
0u32Dirty flags
4f32[3][2][2]Input Gain (Each input has 12 channels)
52f32Rate multiplier (1.0x == native DSP rate)
56u8Interpolation mode
57u8Polyphase filter select
58u16bit[0]: Simple Filter enabled, bit[1]: Biquadratic Filter enabled
60SimpleFilterSimple Filter (One pole normalized recursive linear filter)
64BiquadFilterBiquadratic Filter (Two poles two zeros normalized recursive linear filter)
74u16Bitmap of which buffers in queue are dirty
76Buffer[4]Buffer queue
156u32-
160u16Is Active
162u16Sync Count
164u32Play position
1684?
172u32Physical address of embedded buffer
176u32Number of samples in embedded buffer
180u16Format
182AdpcmDataADPCM data associated with embedded buffer
188u16bit[0]: ADPCM updated?; bit[1]: Is looping?r
190u16Buffer Id of embedded buffer

There is a 2 sample delay in this preprocessing stage, likely due to the interpolation step.

Format #

This is a u16.

BitsDesciption
0-1Number of channels: 0,1,3 = mono; 2 = stereo
2-3Buffer codec: 0:PCM8; 1:PCM16; 2:ADPCM
5Fade

Buffer #

OffsetTypeDescription
0u32Physical Address
4u32Sample Count
8AdpcmDataADPCM data
14u8ADPCM data dirty?
15u8Looping?
16u16Buffer Id
18u16-

Adpcm Data #

0u8ADPCM predictor/scale
1u8-
2s16ADPCM y[n-1]
4s16ADPCM y[n-2]

Simple Filter #

This is a standard single-pole filter. The fall-off is 6dB per octave as you would expect.

OffsetTypeDescription
0s1.15b0
2s1.15a1 (negated)

Biquad Filter #

This is a 🔗 biquadratic filter.

OffsetTypeDescription
0s2.14a2 (negated)
2s2.14a1 (negated)
4s2.14b2
6s2.14b1
8s2.14b0

Input status #

Read only. This structure is set by the DSP. This structure is 12 bytes long and there are 24 of them.

OffsetTypeDescription
0u8Input Enabled?
1u8Dirty flag for buffer id, set to 1 when buffer (after the first) starts playing
2u16Sync count
4u32Position (number of samples) into current buffer playback
8u16Buffer id of the buffer that’s just started playing.
10u16-

Input ADPCM coefficients #

This is a 32 byte long structure. There are 24 of them.

OffsetTypeDescription
0s5.11[16]ADPCM coefficents

DSP configuration #

Delay Effect #

Delay with feedback.

Length of delay is expressed in terms of number of audio frames (there are 160 samples per audio frame).

Feedback arm only has a gain on it. Under the feedback arm is a single-pole filter with the delay.

Reverb Effect #

Reverb consists of two comb filters and one all-pass filter in standard configuration.

DSP status #

Read only. A 32 byte long structure.

OffsetTypeDescription
0u16?
2u16Number of dropped frames
428 bytes?

Output samples #

Read only. This structure is 640 bytes long. Output is stereo (the 3DS has two speakers).

OffsetTypeDescription
0s16[160]Left-channel Samples
320s16[160]Right-channel Samples

This structure has separate arrays for the left and right channels.

Intermediate mix samples #

Read/Write.

PCM32. Also serves an aux function, allowing the ARM11 to apply custom effects to audio. Internal format of the DSP firmware is quadaphonic audio.

This structure is 5120 bytes long.

OffsetTypeDescription
0IntermediateSample[160]Samples

In contrast to the final output samples, this structure has the left/right channels interleaved.

Intermediate sample #

A quadraphonic sample.

OffsetTypeDescription
0s32Left Channel A
4s32Right Channel A
8s32Left Channel B
12s32Right Channel B

Compressor table #

A precomputed response curve lookup table for the compressor.

Category:DSP