MusicKit  0.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes
SndPerformance Class Reference

Holds the state associated with each sounding (or soon to be) Snd. More...

#import <SndPerformance.h>

List of all members.

Public Member Functions

(id) - initWithSnd:playingAtTime:
 Initialise a performance with a sound and a time to begin playing.
(id) - initWithSnd:playingAtTime:beginAtIndex:endAtIndex:
 Initialise a performance with a sound and a time to begin playing, and the index of the first and last samples of the sound to play.
(id) - initWithSnd:playingAtTime:startPosition:duration:deltaTime:
 Initialise a performance with a sound and a time to begin playing, and the index of the last sample of the sound to play.
(Snd *) - snd
 Returns the Snd instance being played in this performance.
(double) - playTime
 Returns the time the sound is to begin playing.
(id) - setPlayTime:
 Sets the time interval in seconds from the current time the sound is to begin playing.
(long) - playIndex
 Returns the sample to start playing from.
(void) - setPlayIndex:
 Sets the sample to start playing from.
(long) - rewindPlayIndexBySamples:
 Rewinds the sample to start playing from by the supplied number of samples.
(long) - endAtIndex
 Returns the sample to stop playing at.
(long) - startAtIndex
 Returns the sample to start playing at.
(void) - setEndAtIndex:
 Sets the sample to stop playing at.
(void) - setLooping:
 Sets looping during performance on or off.
(BOOL) - looping
 Returns whether this performance loops.
(void) - setLoopStartIndex:
 Sets the sample to start looping from.
(long) - loopStartIndex
 Returns the sample to start looping from.
(void) - setLoopEndIndex:
 Sets the sample at which the performance loops back to the start index (set using setLoopStartIndex:).
(long) - loopEndIndex
 Returns the sample index at the end of the loop.
(void) - stopInFuture:
 Stop the currently playing performance at some time in the future.
(void) - stopNow
 Stops the performance immediately.
(BOOL) - isEqual:
 Compares two performances.
(NSString *) - description
 Returns a string containing a brief description of the performance object.
(BOOL) - isPaused
 Returns if the performance is paused.
(id) - setPaused:
 Pauses the performance.
(id) - pause
 Pauses a performance.
(id) - resume
 Resumes a paused performance.
(BOOL) - isPlaying
 Indicates whether the current performance is actually sounding.
(SndAudioProcessorChain *) - audioProcessorChain
 Returns the SndAudioProcessorChain associated with this performance.
(void) - setAudioProcessorChain:
 Assigns an new SndAudioProcessorChain to effect the performance of a Snd instance.
(long) - retrievePerformBuffer:ofLength:
 Fills the given buffer with sound data, reading from the playIndex up until endAtIndex (which allows us to play a sub-section of a sound).
(BOOL) - atEndOfPerformance
 Tests if the play index has reached the end index, indicating that the performance has completed.
(id) - initWithSnd:playingAtTime:
 Initialise a performance with a sound and a time to begin playing.
(id) - initWithSnd:playingAtTime:beginAtIndex:endAtIndex:
 Initialise a performance with a sound and a time to begin playing, and the index of the first and last samples of the sound to play.
(id) - initWithSnd:playingAtTime:startPosition:duration:deltaTime:
 Initialise a performance with a sound and a time to begin playing, and the index of the last sample of the sound to play.
(Snd *) - snd
 Returns the Snd instance being played in this performance.
(double) - playTime
 Returns the time the sound is to begin playing.
(id) - setPlayTime:
 Sets the time interval in seconds from the current time the sound is to begin playing.
(long) - playIndex
 Returns the sample to start playing from.
(void) - setPlayIndex:
 Sets the sample to start playing from.
(long) - rewindPlayIndexBySamples:
 Rewinds the sample to start playing from by the supplied number of samples.
(long) - endAtIndex
 Returns the sample to stop playing at.
(long) - startAtIndex
 Returns the sample to start playing at.
(void) - setEndAtIndex:
 Sets the sample to stop playing at.
(void) - setLooping:
 Sets looping during performance on or off.
(BOOL) - looping
 Returns whether this performance loops.
(void) - setLoopStartIndex:
 Sets the sample to start looping from.
(long) - loopStartIndex
 Returns the sample to start looping from.
(void) - setLoopEndIndex:
 Sets the sample at which the performance loops back to the start index (set using setLoopStartIndex:).
(long) - loopEndIndex
 Returns the sample index at the end of the loop.
(void) - stopInFuture:
 Stop the currently playing performance at some time in the future.
(void) - stopNow
 Stops the performance immediately.
(BOOL) - isEqual:
 Compares two performances.
(NSString *) - description
 Returns a string containing a brief description of the performance object.
(BOOL) - isPaused
 Returns if the performance is paused.
(id) - setPaused:
 Pauses the performance.
(id) - pause
 Pauses a performance.
(id) - resume
 Resumes a paused performance.
(BOOL) - isPlaying
 Indicates whether the current performance is actually sounding.
(SndAudioProcessorChain *) - audioProcessorChain
 Returns the SndAudioProcessorChain associated with this performance.
(void) - setAudioProcessorChain:
 Assigns an new SndAudioProcessorChain to effect the performance of a Snd instance.
(long) - retrievePerformBuffer:ofLength:
 Fills the given buffer with sound data, reading from the playIndex up until endAtIndex (which allows us to play a sub-section of a sound).
(BOOL) - atEndOfPerformance
 Tests if the play index has reached the end index, indicating that the performance has completed.

Static Public Member Functions

(SndPerformance *) + performanceOfSnd:playingAtTime:
 Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing. Convenience method to performanceOfSnd:playingAtTime:endAtIndex.
(SndPerformance *) + performanceOfSnd:playingAtTime:beginAtIndex:endAtIndex:
 Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing.
(SndPerformance *) + performanceOfSnd:playingAtTime:
 Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing. Convenience method to performanceOfSnd:playingAtTime:endAtIndex.
(SndPerformance *) + performanceOfSnd:playingAtTime:beginAtIndex:endAtIndex:
 Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing.

Protected Attributes

Sndsnd
double playTime
long startAtIndex
long playIndex
long endAtIndex
BOOL paused
SndAudioProcessorChainaudioProcessorChain
BOOL looping
long loopStartIndex
long loopEndIndex

Detailed Description

Holds the state associated with each sounding (or soon to be) Snd.

This differs from a Snd instance itself, since we can have multiple overlapping simultaneous performances of the same (potentially huge) Snd, some looping, others not. We need some way of indicating to the delegate exactly which performance has completed, hence this class. A SndPerformance also has an SndAudioProcessorChain enabling each performance of a sound to be signal processed, including volume fading, panning etc using the audio processor chain "postFader" SndAudioFader.


Member Function Documentation

Returns the SndAudioProcessorChain associated with this performance.

Returns:
The audioProcessorChain associated with this performance

Returns the SndAudioProcessorChain associated with this performance.

Returns:
The audioProcessorChain associated with this performance
- (NSString *) description

Returns a string containing a brief description of the performance object.

Returns:
A string containing a brief description of the performance object.
- (NSString *) description

Returns a string containing a brief description of the performance object.

Returns:
A string containing a brief description of the performance object.
- (long) endAtIndex

Returns the sample to stop playing at.

This sample is not played, that is it is typically initialised with the sound length.

Returns:
Returns the sample index to stop playing at.
- (long) endAtIndex

Returns the sample to stop playing at.

This sample is not played, that is it is typically initialised with the sound length.

Returns:
Returns the sample index to stop playing at.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  seconds 

Initialise a performance with a sound and a time to begin playing.

Convenience method to initWithSnd:playingAtTime:endAtIndex:

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
Returns:
Returns self if able to initialise, nil if unable.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  seconds 

Initialise a performance with a sound and a time to begin playing.

Convenience method to initWithSnd:playingAtTime:endAtIndex:

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
Returns:
Returns self if able to initialise, nil if unable.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  seconds
beginAtIndex: (long)  beginIndex
endAtIndex: (long)  endIndex 

Initialise a performance with a sound and a time to begin playing, and the index of the first and last samples of the sound to play.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
beginIndexThe sample index at which to start playback
endIndexThe sample index at which to stop playback
Returns:
Returns self if able to initialise, nil if unable.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  seconds
beginAtIndex: (long)  beginIndex
endAtIndex: (long)  endIndex 

Initialise a performance with a sound and a time to begin playing, and the index of the first and last samples of the sound to play.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
beginIndexThe sample index at which to start playback
endIndexThe sample index at which to stop playback
Returns:
Returns self if able to initialise, nil if unable.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  playTime
startPosition: (double)  startPosition
duration: (double)  duration
deltaTime: (double)  deltaTime 

Initialise a performance with a sound and a time to begin playing, and the index of the last sample of the sound to play.

Parameters:
sThe Snd instance to begin playing.
playTimeThe time to begin playback.
startPositionThe sample index at which to begin playback.
durationThe duration in seconds of the Snd instance to play.
deltaTimeTBD.
Returns:
Returns self if able to initialise, nil if unable.
- (id) initWithSnd: (Snd *)  s
playingAtTime: (double)  playTime
startPosition: (double)  startPosition
duration: (double)  duration
deltaTime: (double)  deltaTime 

Initialise a performance with a sound and a time to begin playing, and the index of the last sample of the sound to play.

Parameters:
sThe Snd instance to begin playing.
playTimeThe time to begin playback.
startPositionThe sample index at which to begin playback.
durationThe duration in seconds of the Snd instance to play.
deltaTimeTBD.
Returns:
Returns self if able to initialise, nil if unable.
- (BOOL) isEqual: (id)  anotherPerformance

Compares two performances.

Parameters:
anotherPerformance
- (BOOL) isEqual: (id)  anotherPerformance

Compares two performances.

Parameters:
anotherPerformance
- (BOOL) isPaused

Returns if the performance is paused.

Returns:
Boolean - YES/TRUE if the performance is paused. NO if the performance is playing.
- (BOOL) isPaused

Returns if the performance is paused.

Returns:
Boolean - YES/TRUE if the performance is paused. NO if the performance is playing.
- (BOOL) isPlaying

Indicates whether the current performance is actually sounding.

Returns:
Returns YES if the performance is currently sounding, NO if it is paused, has yet to be begin playing or has finished.
- (BOOL) isPlaying

Indicates whether the current performance is actually sounding.

Returns:
Returns YES if the performance is currently sounding, NO if it is paused, has yet to be begin playing or has finished.
- (long) loopEndIndex

Returns the sample index at the end of the loop.

Returns:
Returns the sample index ending the loop.
- (long) loopEndIndex

Returns the sample index at the end of the loop.

Returns:
Returns the sample index ending the loop.
- (BOOL) looping

Returns whether this performance loops.

Returns:
Returns whether this performance loops.
- (BOOL) looping

Returns whether this performance loops.

Returns:
Returns whether this performance loops.
- (long) loopStartIndex

Returns the sample to start looping from.

Returns:
Returns the sample index to start looping from.
- (long) loopStartIndex

Returns the sample to start looping from.

Returns:
Returns the sample index to start looping from.
+ (SndPerformance *) performanceOfSnd: (Snd *)  s
playingAtTime: (double)  seconds 

Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing. Convenience method to performanceOfSnd:playingAtTime:endAtIndex.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
Returns:
Returns the newly created instance if able to initialise, nil if unable.
+ (SndPerformance *) performanceOfSnd: (Snd *)  s
playingAtTime: (double)  seconds 

Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing. Convenience method to performanceOfSnd:playingAtTime:endAtIndex.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
Returns:
Returns the newly created instance if able to initialise, nil if unable.
+ (SndPerformance *) performanceOfSnd: (Snd *)  s
playingAtTime: (double)  seconds
beginAtIndex: (long)  beginIndex
endAtIndex: (long)  endIndex 

Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
beginIndexThe sample index at which to start playback. This sample will be played.
endIndexThe sample index at which to stop playback. This sample will not be played.
Returns:
Returns the newly created instance if able to initialise, nil if unable.
+ (SndPerformance *) performanceOfSnd: (Snd *)  s
playingAtTime: (double)  seconds
beginAtIndex: (long)  beginIndex
endAtIndex: (long)  endIndex 

Create and return an autoreleased instance of SndPerformance with a sound and a time to begin playing.

Parameters:
sThe sound to be played
secondsTime in seconds to start playing the sound
beginIndexThe sample index at which to start playback. This sample will be played.
endIndexThe sample index at which to stop playback. This sample will not be played.
Returns:
Returns the newly created instance if able to initialise, nil if unable.
- (long) playIndex

Returns the sample to start playing from.

Returns:
Returns the sample index to start playing from.
- (long) playIndex

Returns the sample to start playing from.

Returns:
Returns the sample index to start playing from.
- (double) playTime

Returns the time the sound is to begin playing.

Returns:
Returns the time interval in seconds from the current time the sound is to begin playing.
- (double) playTime

Returns the time the sound is to begin playing.

Returns:
Returns the time interval in seconds from the current time the sound is to begin playing.
- (long) retrievePerformBuffer: (SndAudioBuffer *)  bufferToFill
ofLength: (long)  buffLength 

Fills the given buffer with sound data, reading from the playIndex up until endAtIndex (which allows us to play a sub-section of a sound).

playIndex is updated, and looping is respected. In the case of the end of the sound being encountered, a smaller buffer will be filled, and the smaller size is returned.

Parameters:
bufferToFillA SndAudioBuffer that will be filled with samples.
buffLengthThe intended number of samples TODO or bytes? to retrieve.
Returns:
Returns the final buffer length, which may be less than the requested amount in the case of a premature stop, or simply reaching the end of the data.
- (long) retrievePerformBuffer: (SndAudioBuffer *)  bufferToFill
ofLength: (long)  buffLength 

Fills the given buffer with sound data, reading from the playIndex up until endAtIndex (which allows us to play a sub-section of a sound).

playIndex is updated, and looping is respected. In the case of the end of the sound being encountered, a smaller buffer will be filled, and the smaller size is returned.

Parameters:
bufferToFillA SndAudioBuffer that will be filled with samples.
buffLengthThe intended number of samples TODO or bytes? to retrieve.
Returns:
Returns the final buffer length, which may be less than the requested amount in the case of a premature stop, or simply reaching the end of the data.
- (long) rewindPlayIndexBySamples: (long)  numberOfSamplesToRewind

Rewinds the sample to start playing from by the supplied number of samples.

The loop points are respected, such that rewinding a sound that is set to loop before it's loop start index will wrap to the end of the loop. If this isn't wanted, either temporarily disable looping or use setPlayIndex:.

Parameters:
numberOfSamplesToRewindThe number of samples to rewind to where playing should begin from.
Returns:
Returns the new play index as a convience to save calling playIndex.
- (long) rewindPlayIndexBySamples: (long)  numberOfSamplesToRewind

Rewinds the sample to start playing from by the supplied number of samples.

The loop points are respected, such that rewinding a sound that is set to loop before it's loop start index will wrap to the end of the loop. If this isn't wanted, either temporarily disable looping or use setPlayIndex:.

Parameters:
numberOfSamplesToRewindThe number of samples to rewind to where playing should begin from.
Returns:
Returns the new play index as a convience to save calling playIndex.
- (void) setAudioProcessorChain: (SndAudioProcessorChain *)  anAudioProcessorChain

Assigns an new SndAudioProcessorChain to effect the performance of a Snd instance.

Parameters:
anAudioProcessorChain
- (void) setAudioProcessorChain: (SndAudioProcessorChain *)  anAudioProcessorChain

Assigns an new SndAudioProcessorChain to effect the performance of a Snd instance.

Parameters:
anAudioProcessorChain
- (void) setEndAtIndex: (long)  newEndAtIndex

Sets the sample to stop playing at.

The end at index indicates the first sample at which the playback stops, that is, this sample is not played.

Parameters:
newEndAtIndexThe sample index that playing should stop before.
- (void) setEndAtIndex: (long)  newEndAtIndex

Sets the sample to stop playing at.

The end at index indicates the first sample at which the playback stops, that is, this sample is not played.

Parameters:
newEndAtIndexThe sample index that playing should stop before.
- (void) setLoopEndIndex: (long)  newLoopEndIndex

Sets the sample at which the performance loops back to the start index (set using setLoopStartIndex:).

Parameters:
newLoopEndIndexThe sample index at the end of the loop.

This sample index is the last sample of the loop, i.e. it is the last sample heard before the performance loops, the next sample heard will be that returned by -loopStartIndex. The loop end index may be changed while the sound is being performed and regardless of whether the performance is looping.

- (void) setLoopEndIndex: (long)  newLoopEndIndex

Sets the sample at which the performance loops back to the start index (set using setLoopStartIndex:).

Parameters:
newLoopEndIndexThe sample index at the end of the loop.

This sample index is the last sample of the loop, i.e. it is the last sample heard before the performance loops, the next sample heard will be that returned by -loopStartIndex. The loop end index may be changed while the sound is being performed and regardless of whether the performance is looping.

- (void) setLooping: (BOOL)  yesOrNo

Sets looping during performance on or off.

Parameters:
yesOrNoSets looping during performance on or off.
- (void) setLooping: (BOOL)  yesOrNo

Sets looping during performance on or off.

Parameters:
yesOrNoSets looping during performance on or off.
- (void) setLoopStartIndex: (long)  loopStartIndex

Sets the sample to start looping from.

Parameters:
loopStartIndexThe sample index to start looping from.

The loop start index may be changed while the sound is being performed and regardless of whether the performance is looping. This sample index is the first sample of the loop, i.e it is the first sample heard when the performance loops.

- (void) setLoopStartIndex: (long)  loopStartIndex

Sets the sample to start looping from.

Parameters:
loopStartIndexThe sample index to start looping from.

The loop start index may be changed while the sound is being performed and regardless of whether the performance is looping. This sample index is the first sample of the loop, i.e it is the first sample heard when the performance loops.

- (id) setPaused: (BOOL)  isPaused

Pauses the performance.

Parameters:
isPauseda flag to signal whether or not the performance is paused.
Returns:
self
- (id) setPaused: (BOOL)  isPaused

Pauses the performance.

Parameters:
isPauseda flag to signal whether or not the performance is paused.
Returns:
self
- (void) setPlayIndex: (long)  newPlayIndex

Sets the sample to start playing from.

Parameters:
newPlayIndexThe sample index that playing should begin from.
- (void) setPlayIndex: (long)  newPlayIndex

Sets the sample to start playing from.

Parameters:
newPlayIndexThe sample index that playing should begin from.
- (Snd *) snd

Returns the Snd instance being played in this performance.

Returns:
Returns the Snd instance being played in this performance.
- (Snd *) snd

Returns the Snd instance being played in this performance.

Returns:
Returns the Snd instance being played in this performance.
- (long) startAtIndex

Returns the sample to start playing at.

Returns:
Returns the sample index to start playing at.
- (long) startAtIndex

Returns the sample to start playing at.

Returns:
Returns the sample index to start playing at.
- (void) stopInFuture: (double)  inSeconds

Stop the currently playing performance at some time in the future.

Parameters:
inSecondsThe time interval when to stop the performance.
- (void) stopInFuture: (double)  inSeconds

Stop the currently playing performance at some time in the future.

Parameters:
inSecondsThe time interval when to stop the performance.

Member Data Documentation

Effects applied to this particular performance.

- (long) endAtIndex [protected]

The index where the sound will stop before. This marks the sample after the last one to be played, the sample at endAtIndex is not played.

- (long) loopEndIndex [protected]

The sample the loop ends at. This sample is included in the loop.

- (BOOL) looping [protected]

Indicates whether to loop during performance.

- (long) loopStartIndex [protected]

The sample the loop begins at. This sample is included in the loop.

- (BOOL) paused [protected]

Controls whether performance of the Snd is occuring.

- (long) playIndex [protected]

The index where the sound will next play from (using retrievePerformBuffer:).

- (double) playTime [protected]

The time when to initiate playing.

- (Snd *) snd [protected]

The sound being performed.

- (long) startAtIndex [protected]

The index where the sound will begin playing from at the start of a sound performance.


The documentation for this class was generated from the following files: