A: This is a complex issue. The number of voices available is determined by the sum of all resources used by all the active voices. These include:
The real limits are not known yet, but you can play at least 8 variable rate, 16-bit samples with loudness control. Fixed rate samples are much less expensive than variable rate samples and are limited by the 13 input FIFOs. Resonant filters are cheaper than a variable rate sampler.
Allocating DSP Resources
Q: After eight loads of halfmono8.dsp
, the ninth load fails and I receive the error message: "Couldn't allocate DSP resources." Can you explain why?
A: Only eight fit. Halfmono8.dsp
requires 49 DSP code words, and 38 DSP tick(cycles). For code words, the total is 512. The system takes 70, and a mixer4x2.dsp
takes 32. That leaves 410 available. Divide that by 49 yields 8.36 halfmono8
instruments worth of code maximum.
For ticks, the total is 565. The system takes 45, and a mixer4x2.dsp
takes 32, that leaves 488 available. Dividing that by 38 yields 12.84 halfmono8
instruments worth of ticks maximum. The code words are the limiting resource.
sampler.dsp
? Does the number of channels vary with the instrument?
A: Synthesis instruments such as svfilter.dsp
and triangle.dsp
use 0 DMA channels. Mono and stereo sample playing instruments each use one DMA channel. The only instrument that uses two input DMA channels is sampler3d.dsp
. The delay1tap.dsp
instrument uses one output DMA channel and one input DMA channel.
Q: How many DMA channels can be allocated for the DSP?
A: There are 13 INPUT DMA channels used for playing samples. There are four OUTPUT DMA channels used for echo and delay effects.
Q: Could you briefly tell me about the relationship between the DSP and DMA controller?
A: The DSP plays audio samples by reading the sample data from a register in the DSP address space. There is a register for each DMA channel. The register connects to a FIFO which can store up to eight 16 bit sample words. When the FIFO is down to two sample words, a DMA request is issued that fills the FIFO from main memory.
A: The tool is called audiomon
and it resides in $c
(an alias set to
$boot/System/Programs). audiomon
displays a bar graph of DSP resources on the graphics screen. There is also a tool called DumpDSPP.c
that prints to the terminal so it can be used when the graphics screen is busy.
A: The score playing code in the Music library supports dynamic voice allocation. When a voice is needed, the code attempts the following:
AdoptInstrument()
, ScavengeInstrument(), and GetAudioItemInfo() to implement these functions.For an example of using the score player as a sound effects manager, see the example program tsc_soundfx.c.