psx.wiki

Sound Processing Unit (SPU): Difference between revisions

Revision as of 02:46, 23 October 2026
RemmyLee
(GTE, MDEC, controllers, Memory Card, SIO and expansion port at register depth)
Revision as of 02:46, 23 October 2026
RemmyLee
(SPU and CD-ROM at register depth; CPU overview rewritten)
Line 8:Line 8:
## Overview## Overview
−The PlayStation sound system is made up of the SPU and the CD-ROM decoder.[^hw43]+The PlayStation sound system is composed of the SPU and the CD-ROM decoder. The SPU is a 24-voice ADPCM sound source that changes its operating parameters automatically over time, and the CPU operates it through its registers.[^hw14][^hw43] The SPU plays ADPCM sample data from its own local memory at a sampling frequency of 44.1 kHz. It also has a digital reverb and a mixer, which mixes the audio output of the CD-ROM decoder with the SPU's own output before the final audio output.[^hw44]
−The SPU plays ADPCM sample data from its local memory at a sampling frequency of 44.1 kHz.[^hw44]
−
−The CPU operates the SPU.[^hw14]
−
−The SPU has a digital reverb. It also mixes the audio output of the CD-ROM decoder with its own output.[^hw44]
−
−The SPU has the following specifications:
−
Table: SPU specificationsTable: SPU specifications
Line 26:Line 18:
| Sampling frequency | 44.1 kHz || Sampling frequency | 44.1 kHz |
−## Sound Buffer+psx-spx traces the SPU to the S-DSP that Sony designed for the SNES. The PlayStation part has no sound CPU of its own, and its sample memory grew from 64KB to 512KB. It also has 24 voices at 44100 Hz and 16-byte ADPCM blocks with five filters, and its stereo reverb replaced the SNES echo.[^spxintro]
−The sound buffer is a 512KB local memory that supplies waveform data to the sound source. It is not mapped in the CPU address space.[^hw44]+The details are on the following pages:
−The sound buffer holds the ADPCM sound data. It is also the reverb work area.[^hw44]+Table: SPU pages
−The sound buffer also serves as a temporary buffer for sound data on its way to main memory.[^hw44]+| Page | Contents |
+| --- | --- |
+| [SPU Registers](/hardware/spu/registers/) | Every register, transfers to the sound buffer, the SPU interrupt |
+| [SPU ADPCM](/hardware/spu/adpcm/) | Sample block format, loop flags, decoding, interpolation |
+| [SPU ADSR and Volume](/hardware/spu/adsr/) | Envelope and volume sweep encodings |
+| [SPU Reverb](/hardware/spu/reverb/) | Reverb registers, formula, work area, templates |
−DMA can transfer data from main memory to the sound buffer. Sound generation does not need to stop during the transfer.[^hw44]+## Sound Buffer
−## Voice Functions+The sound buffer is a 512KB local memory that supplies waveform data to the sound source. It is not mapped in the CPU address space, so the CPU reaches it only through SPU registers or by DMA.[^hw44][^spxmemmap] The buffer holds the ADPCM sound data and is also the work area of the reverb. It also serves as a temporary buffer when sound data from the CD input or the SPU is sent to main memory. DMA from main memory to the sound buffer does not require sound generation to stop during the transfer.[^hw44]
−Each of the 24 voices has its own settings for the functions below.[^hw45]+libspu does not manage the buffer actively, so data must not be transferred into the reserved areas.[^ovr167] The layout is as follows:
−ADPCM or noise, the left and right volume and reverb on or off are set voice by voice.[^hw44]+Table: Sound buffer memory layout
−### Pitch Transformation+| Address | Contents |
+| --- | --- |
+| 00000h to 003FFh | CD input left, before volume processing |
+| 00400h to 007FFh | CD input right, before volume processing |
+| 00800h to 00BFFh | Voice 1 output after envelope processing |
+| 00C00h to 00FFFh | Voice 3 output after envelope processing |
+| 01000h to 0100Fh | System reserved: the SPU IRQ clear block |
+| 01010h to reverb offset | Waveform data |
+| Reverb offset to 7FFFFh | Reverb work area, size set by the reverb mode |
−The pitch of ADPCM sound data can be varied from -12 octaves to +2 octaves. Steps of a half-tone or less can be set.[^hw45]+Sony gives the first 1000h bytes as the SPU decoded data region and 01000h to 0100Fh as system reserved.[^ovr167] psx-spx gives the four 1KB buffers within the decoded data region.[^spxmemmap] The libspu memory functions SpuInitMalloc(), SpuMalloc(), SpuMallocWithStartAddr() and SpuFree() only keep a table of used areas, which allows simple management of the waveform area.[^ovr167][^ovr168]
−### Pitch Variation by Time+## Voices
−The volume of one voice can vary the pitch of the next voice. The final pitch is NewPitch(n) = (1 + V(n-1)) Pitch(n).[^hw45]+Each of the 24 voices plays ADPCM data from the sound buffer, or the noise generator in its place. libspu sets the following attributes for each voice separately: left and right volume, pitch, the address of the waveform data, the envelope (ADSR) and the loop point. Key on and key off are also set voice by voice.[^ovr164] These attributes may be changed while the voice is sounding. It is therefore possible to vary the interval continuously during a sound, or to change the loop point of looped waveform data while it plays.[^ovr164]
−V(n-1) is the volume of voice n-1, which varies with time. Pitch(n) is the pitch originally set for voice n.[^hw45]+ADPCM or noise, the left and right volume and reverb on or off are set for each voice.[^hw44] The pitch of ADPCM data can be varied from -12 octaves to +2 octaves in steps of a half-tone or less.[^hw45] With two adjoining voices, the volume of one can vary the pitch of the next: NewPitch(n) = (1 + V(n-1)) x Pitch(n), where V(n-1) is the volume of voice n-1 and Pitch(n) is the pitch set for voice n. Sony calls this an LFO effect, and it uses two voices for one tone.[^hw45][^ovr164]
−### Noise Source+The SPU has one noise generator, which uses pseudo random numbers and can replace the waveform data of any voice. The noise tone is varied by changing the noise generation clock, and the envelope still applies to a noise voice.[^hw45][^ovr164] The envelope has separate attack, decay, sustain and release rates and a sustain level. Linear or exponential curves can be chosen, except for decay, which is exponential only.[^hw45] The volume can also change over time apart from the envelope by linear increment, linear decrement, reverse indexed increment or indexed decrement.[^hw46]
−The SPU has a noise generator that uses pseudo random numbers. Any voice can use the noise source in place of ADPCM data from the sound buffer.[^hw45]+## External Inputs
−The noise generation clock sets the noise tone.[^hw45]+The SPU has two external inputs: the CD input and the external digital input. Both are sampled at 44.1 kHz and mixed digitally with the SPU output, and either one can be sent to the reverb.[^ovr168] The CD-ROM decoder plays CD-DA or CD-ROM XA audio. Its output enters the SPU and is mixed with the SPU output, then passes through the reverb unit to the final audio output.[^hw43] The external digital input comes from the expansion port.[^spxinputs]
−### Envelope+The CD input volume is set with SpuSetCommonAttr(). SpuInit() resets the CD volume to zero. The order of initialization is therefore CDInit() and SpuInit() before the CD volume is set.[^ovr168] On the [CD-ROM](/hardware/cd-rom/) side, four attenuators in the decoder set the mix of the left and right channels.[^ovr115]
−The envelope has separate rates for attack, decay, sustain and release. The sustain level can also be set.[^hw45]+## Decoded Data Transfer
−Each envelope rate follows a linear curve or an exponential curve. Decay uses the exponential curve only.[^hw45]+The SPU writes the first 1000h bytes of the sound buffer 16 bits at a time at each 44.1 kHz clock. It writes the CD input after volume processing and voices 1 and 3 after envelope processing. Each of the four buffers is 400h bytes and is divided into two halves.[^ovr168] By choosing which half to read, a program can take up to 100 samples (100 / 44100 = 0.0022 seconds) at a time. SpuReadDecodeData() performs this transfer.[^ovr168] DMA can then move the data to main memory, where the CD input or SPU output can be processed.[^hw46]
−### Volume+## Initialization
−Volume variation is set apart from the envelope.[^hw46]+libspu is set up in the following order.[^ovr168][^ovr169]
−The volume can stay constant or change by one of the following:+Table: SPU initialization
−Table: Volume variation+| Step | Action |
+| --- | --- |
+| 1 | Call SpuInit() before any other libspu function |
+| 2 | Transfer data to the sound buffer, set up reverb, and set the main volume, CD input and external input with SpuSetCommonAttr(), in any order |
+| 3 | Set voice attributes with SpuSetVoiceAttr() |
+| 4 | Key on voices with SpuSetKey() or SpuSetKeyOnWithAttr() |
+| 5 | Call SpuQuit() to stop all SPU processing, and SpuStart() to restart it |
−| Variation |+libspu has no time control functions; libapi provides them. Between two calls that set the same function, at least 1/44100 second of SPU processing must pass.[^ovr163]
−| --- |
−| Linear increment |
−| Linear decrement |
−| Reverse indexed increment |
−| Indexed decrement |
−## Reverb+## Audio Output
−The digital reverb uses the sound buffer as its work area.[^hw46]+The standard audio cables carry separate left and right signals. A mono television receives only one of them, so psx-spx recommends an option that turns off stereo effects and sends equal volume to both sides.[^spxmono]
−Reverb is set on or off for each voice and for the CD input.[^hw46]
−
−## CD-ROM Decoder Input
−
−The CD-ROM decoder plays audio from CD-DA or CD-ROM XA data. Its output enters the SPU and is mixed with the SPU output.[^hw43]
−
−The mixed signal passes through the reverb unit to become the final audio output.[^hw43]
−
−The decoder has a built-in mixer of 4 attenuators. The attenuation of each one sets the mix of the stereo output.[^hw43]
−
−## Sound Data Transmission to Main Memory
−
−The SPU writes two kinds of data to a fixed area of the sound buffer at every sample (44.1 kHz).[^hw46]
−
−The first is the CD input after its volume is applied. The second is the output of 2 specific voices after their envelopes are applied.[^hw46]
−
−DMA can transfer this data to main memory for processing.[^hw46]
−
## References## References
Line 108:Line 96:
[^hw45]: Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 4-5, Figure 4-4.[^hw45]: Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 4-5, Figure 4-4.
[^hw46]: Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 4-6, Figure 4-5.[^hw46]: Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 4-6, Figure 4-5.
+[^ovr115]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 11-5.
+[^ovr163]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 16-3.
+[^ovr164]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 16-4, Table 16-1.
+[^ovr167]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 16-7, Figure 16-1.
+[^ovr168]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 16-8.
+[^ovr169]: Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 16-9.
+[^spxintro]: psx-spx. Sound Processing Unit (SPU). https://psx-spx.consoledev.net/soundprocessingunitspu/
+[^spxmemmap]: psx-spx. Sound Processing Unit (SPU), SPU Memory layout (512Kbyte RAM). https://psx-spx.consoledev.net/soundprocessingunitspu/
+[^spxinputs]: psx-spx. Sound Processing Unit (SPU), Additional Sound Inputs. https://psx-spx.consoledev.net/soundprocessingunitspu/
+[^spxmono]: psx-spx. Sound Processing Unit (SPU), Mono/Stereo Audio Output. https://psx-spx.consoledev.net/soundprocessingunitspu/