Err spAddSoundFile (SPSound **resultSound, SPPlayer *player, const char *fileName)
This function opens the specified AIFF file and scans collects its properties (e.g. number of channels, size of frame, number of frames, markers, etc.). The sound is checked for sample frame formatting compatibility with the other SPSounds in the SPPlayer and for buffer size compatibility. A mismatch causes an error to be returned.
Once that is done, all of the markers from the AIFF file are translated int o SPMarkers. Additionally the following special markers are created:
SP_MARKER_NAME_BEGIN - set to the beginning of the sound data
SP_MARKER_NAME_END - set to the end of the sound data
SP_MARKER_NAME_SUSTAIN_BEGIN - set to the beginning of the sustain loop if the sound file has a sustain loop.
SP_MARKER_NAME_SUSTAIN_END - set to the end of the sustain loop if the sound file has a sustain loop.
SP_MARKER_NAME_RELEASE_BEGIN - set to the beginning of the release loop if the sound file has a release loop.
SP_MARKER_NAME_RELEASE_END - set to the end of the release loop if the sound file has a release loop.
The file is left open for the entire life of this type of SPSound for later reading by the player.
The length of the sound file and all of its markers must be DMA-aligned or else this function will return ML_ERR_BAD_SAMPLE_ALIGNMENT.
All SPSounds added to an SPPlayer are automatically disposed of when the SPPlayer is deleted with spDeletePlayer()
(by calling spRemoveSound()
). You can manually dispose of an SPSound with spRemoveSound()
.
Since all SPSounds belonging to an SPPlayer are played by the same sample player instrument, they must all have the same frame sample frame characteristics (width, number of channels, compression type, and compression ratio).
SPSound to SPSound cross verification is done: an error is returned if they don't match. However, there is no way to verify the correctness of sample frame characteristics for the instrument supplied to spCreatePlayer()
.
If frame size (in bytes) < 4, then it must divide into 4 evenly.
If frame size (in bytes) > 4, then it must be a multiple of 4.
spRemoveSound
(), spAddSample()