# How Do I Manage Multiple Sound Effects?

There are several ways to manage multiple sound effects, depending on the nature of the sound effects.

If you have a few Samples and they can be played by instruments that fit in the DSP at the same time, you can do the following:

1. Load all the instruments and samples.
2. Attach the samples.
3. Connect all the instruments to a mixer.
4. Call `StartInstrument()` to trigger the sound effect for the appropriate instrument.

If the instruments do not all fit in the DSP at the same time, but the Samples are all of the same format, you can do the following:

1. Load several instruments and connect them to a mixer as above.

2. Load all of the samples.

3. Attach all of the samples to each instrument.

4. Keep track of the attachments returned by `AttachSample()` in arrays.

5. Set the attachment flags to AF_ATTF_NOAUTOSTART`|`AF_ATTF_FATLADYSINGS using `SetAudioItemInfo()` so that you can start the instrument without triggering any particular sample.

6. Start each of the instruments playing.

7. Call `StartAttachment()` when you want to trigger a sample on a particular instrument for the appropriate attachment.

8. Call `GetAudioItemInfo()` with AF_TAG_STATUS to determine which instrument is stopped when you want to trigger the next attachment. See How Do I Play a Long Sound File? for more details.

If you have multiple kinds of instruments, you need a more sophisticated dynamic voice allocation scheme. You can use the voice allocator that is part of the score playing utility in the Music library. See the example file tsc_soundfx.c.

### For More Information

See Preparing Instruments, and Playing Instruments, for complete programming details.

See Audio Folio Calls, in the 3DO Music and Audio Programmer's Reference for descriptions of the calls.