tsc_soundfx
To run this program:
1) Install the sample library from the recent 3DO tools disk as documented.
If you don't have the sample library, edit this program to use your own samples. Search for .aiff.
2) Run the program, follow printed instructions.
The idea behind this program is that one can use the virtual MIDI routines
in the music library as a simple sound effects manager. You can assign
samples to channels, and then pay those samples using
StartScoreNote()
. This will take advantage of the voice
allocation, automatic mixer connections, and other management code already
used for playing scores. You do not have to play sequences or load MIDI
files to do this.
You can load your samples based on a PIMap text file using the
LoadPIMap()
routine. This is documented in the manual under
score playing. You may also load the samples yourself and put them in the
PIMap which will give you more control. This example program shows you how
to do that. Samples are assigned to Program Numbers at this step.
Assigning program numbers to channels is accomplished by calling
ChangeScoreProgram()
. Once you have assigned a program to a
channel, you can play the sound by calling:
StartScoreNote (scon, Channel, Note, Velocity);
2) Prior to music.lib V24, you needed to be careful when assigning high priorities. Higher priority instruments never got stolen for lower priority instruments in that scheme. Thus you could clog up the DSPP if you have a high priority instrument with MaxVoices>1 and are also trying to play lower priority instruments. Starting with music.lib V24, higher priority instruments can be stolen by lower priority instruments if the higher priority instruments are stopped. As in the original voice stealing algorithm, voices do not get stolen from higher priority instruments if they are still playing at all (started or released).
3) Samples that are attached to an InsTemplate are deleted when the
Template is deleted. You can detach the sample first by calling
DeleteAttachment()
if you don't want this to happen.
4) You can share the ScoreContext with code that plays a score as long as you don't overlap the channels or program numbers. You might restrict scores to channels 0-7 and programs 0-19. You could then use channels 8-15 and programs 20-39 for sound effects. The advantage of this is that they share the same voice allocation and thus resources will be shared between them. If desired, you could instead use separate independent ScoreContexts.
CreateScoreContext