DSP Memory Region: Difference between revisions

Merry (talk | contribs)
Peachy (talk | contribs)
No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Some of this is known to be incorrect. I'll correct this in a few months after a bit more RE work. [[User:Merry|Merry]] ([[User talk:Merry|talk]]) 21:10, 28 January 2016 (CET)'''
''Note that everything below may vary depending on the exact DSP firmware used and different variants have slightly different behaviours.''
 
----
 
*Note that everything below will 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 [[DSP:ReadPipe|reading channel 2 of the DSP pipe]]. A list of structures in the order the DSP addresses are read from the pipe follows:
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 [[DSP:ReadPipe|reading channel 2 of the DSP pipe]]. A list of structures in the order the DSP addresses are read from the pipe follows:
Line 33: Line 29:
13. Unknown Coefficients
13. Unknown Coefficients


14. Unknown Coefficients
14. Surround sound biquad filter 1


15. Unknown Coefficients
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).  
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).  
Line 42: Line 38:


== Frame Count ==
== 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 ==
== Input Config ==
Line 123: Line 125:
| 180
| 180
| u16
| u16
| bits[0:1]: 1 = mono, 2 = stereo; bits[2:3]: buffer format, bits[5]: fade in
| Format
|-
|-
| 182
| 182
Line 136: Line 138:
| u16
| u16
| Buffer Id of embedded buffer
| Buffer 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.
{| class="wikitable"
|-
| Bits
| Desciption
|-
| 0-1
| Number of channels: 0,1,3 = mono; 2 = stereo
|-
| 2-3
| Buffer codec: [[BCWAV#Encoding|0:PCM8; 1:PCM16; 2:ADPCM]]
|-
| 5
| Fade
|}
|}


Line 208: Line 231:
|-
|-
| 0
| 0
| s16
| s1.15
| b0
| b0
|-
|-
| 2
| 2
| s16
| s1.15
| a1
| a1 (negated)
|}
 
=== Biquad Filter ===
 
This is a [[wikipedia:Digital_biquad_filter|biquadratic filter]].
 
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| s2.14
| a2 (negated)
|-
| 2
| s2.14
| a1 (negated)
|-
| 4
| s2.14
| b2
|-
| 6
| s2.14
| b1
|-
| 8
| s2.14
| b0
|}
|}


Line 232: Line 286:
| 1
| 1
| u8
| u8
| Dirty flag for previous buffer id.
| Dirty flag for buffer id, set to 1 when buffer (after the first) starts playing
|-
|-
| 2
| 2
Line 244: Line 298:
| 8
| 8
| u16
| u16
| Buffer id of last buffer that was played
| Buffer id of the buffer that's just started playing.
|-
|-
| 10
| 10
Line 252: Line 306:


== Input ADPCM coefficients ==
== Input ADPCM coefficients ==
This is a 32 byte long structure. There are 24 of them.
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| s5.11[16]
| ADPCM coefficents
|}


== DSP configuration ==
== DSP configuration ==
Line 264: Line 331:


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


== DSP status ==
== DSP status ==


Read only.
Read only. A 32 byte long structure.
 
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| u16
| ?
|-
| 2
| u16
| Number of dropped frames
|-
| 4
| 28 bytes
| ?
|}


== Output samples ==
== Output samples ==


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


PCM16.
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| s16[160]
| Left-channel Samples
|-
| 320
| s16[160]
| Right-channel Samples
|}
 
This structure has separate arrays for the left and right channels.


== Intermediate mix samples ==
== Intermediate mix samples ==
Line 279: Line 382:
Read/Write.
Read/Write.


PCM32. Also serves an aux function, allowing the ARM11 to apply custom effects to audio.
PCM32. Also serves an aux function, allowing the ARM11 to apply custom effects to audio. Internal format of the DSP firmware is quadraphonic audio.
 
This structure is 5120 bytes long.
 
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| IntermediateSample[160]
| Samples
|}
 
In contrast to the final output samples, this structure has the left/right channels interleaved.
 
=== Intermediate sample ===
 
A quadraphonic sample.
 
{| class="wikitable"
|-
| Offset
| Type
| Description
|-
| 0
| s32
| Left Channel A
|-
| 4
| s32
| Right Channel A
|-
| 8
| s32
| Left Channel B
|-
| 12
| s32
| Right Channel B
|}


== Compressor table ==
== Compressor table ==


A precomputed response curve lookup table for the compressor.
A precomputed response curve lookup table for the compressor.
[[Category:DSP]]