# Music Library Calls

This chapter describes the Music library function calls. The calls are grouped by the Music library component they relate to, as follows:

- Juggler
- Score playing
- Sound files
- Sound player
- Sound spooler

The lists below provide a quick summary of each, followed by the page number of the folio call. For program examples using these calls, refer to the source code file spoolsoundfile.c in the example directory of the Portfolio release.

## Juggler

### Classes

- `CollectionClass` Multiple parallel sequences and collections.
- `JuggleeClass` Root Juggler class.
- `SequenceClass` A single sequence of events.

### Function Calls

- `AbortObject` Abnormally stops a Juggler object.
- `AllocObject` Allocates memory for an object.
- `BumpJuggler` Bumps the Juggler data-structure index.
- `CreateObject` Creates an object of the given class.
- `DefineClass` Defines a class of objects.
- `DestroyObject` Destroys an object.
- `FreeObject` Frees memory allocated for an object.
- `GetNthFromObject` Gets the nth element of a collection.
- `GetObjectInfo` Gets the current settings of an object.
- `InitJuggler` Initializes the Juggler mechanism for controlling events.
- `PrintObject` Prints debugging information about an object.
- `RemoveNthFromObject` Removes the nth element of a collection.
- `SetObjectInfo` Sets values in the object based on tag arguments.
- `StartObject` Starts an object so the Juggler will play it.
- `StopObject` Stops an object so the Juggler won't play it.
- `TermJuggler` Terminates the Juggler mechanism for controlling events.
- `ValidateObject` Validates an object.

## Score Playing

- `ChangeScoreControl` Changes a MIDI control value for a channel.
- `ChangeScorePitchBend` Changes a channel's pitch bend value.
- `ChangeScoreProgram` Changes the MIDI program for a channel.
- `ConvertPitchBend` Converts a MIDI pitch bend value into frequency multiplier.
- `CreateScoreContext` Allocates a score context.
- `DeleteScoreContext` Deletes a score context.
- `DisableScoreMessages` Enable or disable printed messages during score playback.
- `FreeChannelInstruments` Frees all of a MIDI channel's instruments.
- `GetScoreBendRange` Gets the current pitch bend range value for a score context.
- `InitScoreDynamics` Sets up dynamic voice allocation.
- `InitScoreMixer` Creates and initializes a mixer instrument for MIDI score playback.
- `InterpretMIDIEvent` Interprets MIDI events within a MIDI object.
- `InterpretMIDIMessage` Executes a MIDI message.
- `LoadPIMap` Loads a program-instrument map from a text file.
- `MFDefineCollection` Creates a Juggler collection from a MIDI file image in RAM.
- `MFLoadCollection` Loads a set of sequences from a MIDI file.
- `MFLoadSequence` Loads a sequence from a MIDI file.
- `MFUnloadCollection` Unloads a MIDI collection.
- `NoteOffIns` Turns off a note played by an instrument.
- `NoteOnIns` Turns on a note for an instrument.
- `PurgeScoreInstrument` Purges an unused instrument from a ScoreContext.
- `ReleaseScoreNote` Releases a MIDI note, uses voice allocation.
- `SelectSamplePlayer` Gets the name of the instrument to play the sample.
- `SetPIMapEntry` Specifies the instrument to use when a MIDI program change occurs.
- `SetScoreBendRange` Sets the current pitch bend range value for a score context.
- `StartScoreNote` Starts a MIDI note, uses voice allocation.
- `StopScoreNote` Stop a MIDI note w/o releasing it, uses voice allocation.
- `TermScoreMixer` Dispose of mixer created by InitScoreMixer().
- `UnloadPIMap` Unloads instrument templates loaded previously with PIMapfile.

## Sound Files

- `CloseSoundFile` Closes a SoundFilePlayer data structure and unloads a sound file.
- `CreateSoundFilePlayer` Creates a SoundFilePlayer data structure to play sound files.
- `DeleteSoundFilePlayer` Deletes a SoundFilePlayer data structure.
- `LoadSoundFile` Preloads the first part of a sound file.
- `OpenSoundFile` Creates a SoundFilePlayer data structure and loads a sound file.
- `ReadSoundFile` Reads a sound file.
- `RewindSoundFile` Rewinds a sound file player.
- `ServiceSoundFile` Spools a sound file from disk to a sound buffer.
- `StartSoundFile` Begins playing a sound file.
- `StopSoundFile` Stops playing a sound file.
- `UnloadSoundFile` Unloads a sound file.

## Sound Player

- `spAddMarker` Add a new SPMarker to an SPSound.
- `spAddSample` Create an SPSound for a Sample Item.
- `spAddSoundFile` Create an SPSound for an AIFF sound file.
- `spBranchAtMarker` Set up a static branch at a marker.
- `spClearDefaultDecisionFunction` Clears global decision function.
- `spClearMarkerDecisionFunction` Clears a marker decision function.
- `spContinueAtMarker` Clear static branch at a marker.
- `spCreatePlayer` Create an SPPlayer.
- `SPDecisionFunction` Typedef for decision callback functions
- `spDeletePlayer` Delete an SPPlayer.
- `spDumpPlayer` Print debug information for sound player
- `spFindMarkerName` Return pointer an SPMarker by looking up its name.
- `spGetMarkerName` Get name of an SPMarker.
- `spGetMarkerPosition` Get position of an SPMarker.
- `spGetPlayerFromSound` Get SPPlayer that owns an SPSound.
- `spGetPlayerSignalMask` Get set of signals player will send to client.
- `spGetPlayerStatus` Get current status of an SPPlayer.
- `spGetSoundFromMarker` Get SPSound that owns an SPMarker.
- `spIsSoundInUse` Determines if SPPlayer is currently reading from a particular SPSound.
- `spLinkSounds` Branch at end of one sound to beginning of another.
- `spLoopSound` Branch at end of sound back to the beginning.
- `spPause` Pause an SPPlayer.
- `spRemoveMarker` Manually remove an SPMarker from an SPSound.
- `spRemoveSound` Manually remove an SPSound from an SPPlayer.
- `spResume` Resume playback of an SPPlayer after being paused.
- `spService` Service SPPlayer
- `spSetBranchAction` Set up an SPAction to branch to the specified marker.
- `spSetDefaultDecisionFunction` Install a global decision function to be called for every marker.
- `spSetMarkerDecisionFunction` Install a marker decision function.
- `spSetStopAction` Set up an SPAction to stop reading.
- `spStartPlaying` Begin emitting sound for an SPPlayer.
- `spStartReading` Start SPPlayer reading from an SPSound.
- `spStop` Stops an SPPlayer
- `spStopAtMarker` Stop when playback reaches marker.

## Sound Spooler

- `SoundBufferFunc` SoundSpooler callback function typedef.
- `ssplAbort` Abort SoundSpooler buffers in active queue.
- `ssplAttachInstrument` Attach new sample player instrument to SoundSpooler.
- `ssplCreateSoundSpooler` Create a SoundSpooler.
- `ssplDeleteSoundSpooler` Delete a SoundSpooler.
- `ssplDetachInstrument` Delete a SoundSpooler.
- `ssplDumpSoundBufferNode` Print debug info for SoundBufferNode.
- `ssplDumpSoundSpooler` Print debug info for SoundSpooler.
- `ssplGetSBMsgClass` Get class of message passed to SoundBufferFunc.
- `ssplGetSequenceNum` Get Sequence Number of a SoundBufferNode.
- `ssplGetSpoolerStatus` Get SoundSpooler status flags.
- `ssplGetUserData` Get User Data from a SoundBufferNode.
- `ssplIsSpoolerActive` Test if spooler has anything in its active queue.
- `ssplPause` Pauses the SoundSpooler
- `ssplPlayData` Waits for next available buffer then sends a block full of data to the spooler. (convenience routine).
- `ssplProcessSignals` Process completion signals that have been received.
- `ssplRequestBuffer` Asks for an available buffer.
- `ssplReset` Reset Sound Spooler.
- `ssplResume` Resume SoundSpooler playback.
- `ssplSendBuffer` Send a buffer full of data.
- `ssplSetBufferAddressLength` Attach sample data to a SoundBufferNode.
- `ssplSetSoundBufferFunc` Install new SoundBufferFunc in SoundSpooler.
- `ssplSetUserData` Store user data in a SoundBufferNode.
- `ssplSpoolData` Send a block full of data. (convenience routine)
- `ssplStartSpooler` Start SoundSpooler.
- `ssplStartSpoolerTags` Start SoundSpooler with tags.
- `ssplStopSpooler` Stop SoundSpooler.
- `ssplUnrequestBuffer` Return an unused buffer to the sound spooler.
- `UserBufferProcessor` Callback function called by ssplProcessSignals(), ssplAbort(), and ssplReset().