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

A stream client is responsible for audio streaming, signal processing and synthesis. More...

#import <SndStreamClient.h>

Inheritance diagram for SndStreamClient:
SndPlayer SndPlayer SndStreamInput SndStreamInput SndStreamRecorder SndStreamRecorder

List of all members.

Public Member Functions

(NSString *) - description
 Describes SndStreamClient.
(id) - welcomeClientWithInputBuffer:outputBuffer:manager:
 Initialize the client with a buffer showing manager format and start its thread.
(BOOL) - startProcessingNextBufferWithInput:nowTime:
 Initiates the generation of the next buffer which will be retrieved by the SndStreamMixer in the next iteration.
(double) - preemptQueuedStream
 Any audio buffers which have been processed and awaiting to be retrieved by the SndStreamMixer/SndStreamManager are preempted, clearing any sounds such that any new buffer processed will be mixed without waiting for earlier processed buffers to be mixed.
(void) - processingThread
 Root method for the synthesis thread.
(SndAudioBuffer *) - outputBuffer
 Accessor for the currently exposed output buffer.
(SndAudioBuffer *) - synthOutputBuffer
 Accessor for the current synthesis buffer.
(void) - rotateSynthOutputBuffer
 Moves the synthOutputBuffer onto the processed section of the queue, replacing it with the next empty pending buffer.
(SndAudioBuffer *) - synthInputBuffer
 Accessor for the current input buffer.
(void) - finishStreaming
 Tell the client to finish streaming.
(void) - processBuffers
 The main synthesis/processing thread method.
(double) - synthesisTime
 Return the client's current SYNTHESIS time.
(void) - resetTime:
 Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.
(double) - streamTime
 Return the global (the MANAGER'S) current time.
(BOOL) - isActive
 Returns whether the client is active.
(id) - setDetectPeaks:
 enables / disables peak detection
(id) - getPeakLeft:right:
 Get the most recent peak values for the stereo stream.
(BOOL) - generatesOutput
 Returns whether the client is an audio-producer (synthesizer, FX)
(BOOL) - needsInput
 Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)
(id) - setGeneratesOutput:
 Determines whether the client's output buffer will be considered for mixing downstream.
(id) - setNeedsInput:
 Sets whether the client requires an input audio stream or not.
(id) - lockOutputBuffer
 Blocks calling thread until outputBuffer is available for locking.
(id) - unlockOutputBuffer
 Releases lock on the outputBuffer.
(id) - prepareToStreamWithBuffer:
 Prepare to stream with buffers that look like the supplied buffer.
(id) - didFinishStreaming
 streaming thread is shutting down message.
(SndAudioProcessorChain *) - audioProcessorChain
 Returns the client's SndAudioProcessorChain.
(void) - setAudioProcessorChain:
 Assigns a replacement audio processor chain.
(void) - setDelegate:
 Sets the client's delegate object.
(id) - delegate
 Accessor method to the delegate member.
(int) - inputBufferCount
(int) - outputBufferCount
(BOOL) - setInputBufferCount:
 Sets the input buffer queue length (only when client is NOT active)
(BOOL) - setOutputBufferCount:
 Sets the output buffer queue length (only when client is NOT active)
(double) - outputLatencyInSeconds
 Calculates the stream latency of the client.
(long) - outputLatencyInSamples
 Calculates the stream latency of the client.
(long) - instantaneousOutputLatencyInSamples
 Calculates the current output stream latency of the client.
(long) - instantaneousInputLatencyInSamples
 Calculates the current input stream latency of the client.
(NSString *) - clientName
 Accessor to the client name.
(id) - setClientName:
 Sets the client's name.
(id) - offlineProcessBuffer:nowTime:
 To come.
(NSString *) - description
 Describes SndStreamClient.
(id) - welcomeClientWithInputBuffer:outputBuffer:manager:
 Initialize the client with a buffer showing manager format and start its thread.
(BOOL) - startProcessingNextBufferWithInput:nowTime:
 Initiates the generation of the next buffer which will be retrieved by the SndStreamMixer in the next iteration.
(double) - preemptQueuedStream
 Any audio buffers which have been processed and awaiting to be retrieved by the SndStreamMixer/SndStreamManager are preempted, clearing any sounds such that any new buffer processed will be mixed without waiting for earlier processed buffers to be mixed.
(void) - processingThread
 Root method for the synthesis thread.
(SndAudioBuffer *) - outputBuffer
 Accessor for the currently exposed output buffer.
(SndAudioBuffer *) - synthOutputBuffer
 Accessor for the current synthesis buffer.
(void) - rotateSynthOutputBuffer
 Moves the synthOutputBuffer onto the processed section of the queue, replacing it with the next empty pending buffer.
(SndAudioBuffer *) - synthInputBuffer
 Accessor for the current input buffer.
(void) - finishStreaming
 Tell the client to finish streaming.
(void) - processBuffers
 The main synthesis/processing thread method.
(double) - synthesisTime
 Return the client's current SYNTHESIS time.
(void) - resetTime:
 Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.
(double) - streamTime
 Return the global (the MANAGER'S) current time.
(BOOL) - isActive
 Returns whether the client is active.
(id) - setDetectPeaks:
 enables / disables peak detection
(id) - getPeakLeft:right:
 Get the most recent peak values for the stereo stream.
(BOOL) - generatesOutput
 Returns whether the client is an audio-producer (synthesizer, FX)
(BOOL) - needsInput
 Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)
(id) - setGeneratesOutput:
 Determines whether the client's output buffer will be considered for mixing downstream.
(id) - setNeedsInput:
 Sets whether the client requires an input audio stream or not.
(id) - lockOutputBuffer
 Blocks calling thread until outputBuffer is available for locking.
(id) - unlockOutputBuffer
 Releases lock on the outputBuffer.
(id) - prepareToStreamWithBuffer:
 Prepare to stream with buffers that look like the supplied buffer.
(id) - didFinishStreaming
 streaming thread is shutting down message.
(SndAudioProcessorChain *) - audioProcessorChain
 Returns the client's SndAudioProcessorChain.
(void) - setAudioProcessorChain:
 Assigns a replacement audio processor chain.
(void) - setDelegate:
 Sets the client's delegate object.
(id) - delegate
 Accessor method to the delegate member.
(int) - inputBufferCount
(int) - outputBufferCount
(BOOL) - setInputBufferCount:
 Sets the input buffer queue length (only when client is NOT active)
(BOOL) - setOutputBufferCount:
 Sets the output buffer queue length (only when client is NOT active)
(double) - outputLatencyInSeconds
 Calculates the stream latency of the client.
(long) - outputLatencyInSamples
 Calculates the stream latency of the client.
(long) - instantaneousOutputLatencyInSamples
 Calculates the current output stream latency of the client.
(long) - instantaneousInputLatencyInSamples
 Calculates the current input stream latency of the client.
(NSString *) - clientName
 Accessor to the client name.
(id) - setClientName:
 Sets the client's name.
(id) - offlineProcessBuffer:nowTime:
 To come.

Static Public Member Functions

(id) + streamClient
 Factory method to creates and initializes an autoreleased SndStreamClient instance.
(id) + streamClient
 Factory method to creates and initializes an autoreleased SndStreamClient instance.

Protected Attributes

SndAudioBufferexposedOutputBuffer
SndAudioBuffersynthOutputBuffer
SndAudioBuffersynthInputBuffer
SndAudioBufferQueueoutputQueue
SndAudioBufferQueueinputQueue
NSConditionLock * synthThreadLock
NSConditionLock * outputBufferLock
NSConditionLock * managerConnectionLock
BOOL active
BOOL needsInput
BOOL generatesOutput
SndAudioProcessorChainprocessorChain
SndStreamManagermanager
id delegate
double clientNowTime
double lastManagerTime
NSString * clientName

Detailed Description

A stream client is responsible for audio streaming, signal processing and synthesis.

A SndStreamClient provides basic streaming services such as double buffering, thread handling, automatic start up and and shut down of lower-level streaming services. Each SndStreamClient instance has a SndAudioProcessorChain instance, so each client can be part of a signal processing chain.

To interpret the operation and performance of the input and output queues, the output queue holds the empty (ready to be modified), buffers in the pending portion of the queue, and the synthesised (waiting to be played), buffers in the processed portion of the queue. Conversely, the input queue's processed portion holds those buffers which have been read and processed and are free to be overwritten with newly received data, while the pending portion of the queue holds recorded audio that is yet to be processed. Therefore, the [inputQueue pendingBuffersCount] indicates the amount of system input latency, [outputQueue processedBuffersCount] indicates the amount of system output latency.

In the processing thread, the input operation is to retrieve ("pop") the next available pending buffer. Additionally, the output operation is to pop the next available pending buffer. The input synth buffer is then used to process and synthesise into the output synth buffer. That output synth buffer is then processed via an SndAudioProcessorChain and pushed onto the output buffer queue for retrieval by the playback engine.


Member Function Documentation

Returns the client's SndAudioProcessorChain.

Returns:
Reference to the data member audioProcessorChain

Returns the client's SndAudioProcessorChain.

Returns:
Reference to the data member audioProcessorChain
- (NSString *) clientName

Accessor to the client name.

Returns:
Returns the NSString with the client's name.
- (NSString *) clientName

Accessor to the client name.

Returns:
Returns the NSString with the client's name.
- (id) delegate

Accessor method to the delegate member.

Returns:
The stream client's delegate object
- (id) delegate

Accessor method to the delegate member.

Returns:
The stream client's delegate object
- (NSString *) description

Describes SndStreamClient.

Describes SndStreamClient

Returns:
Returns an NSString describing the SndStreamClient.

Reimplemented in SndPlayer, SndPlayer, SndStreamRecorder, and SndStreamRecorder.

- (NSString *) description

Describes SndStreamClient.

Describes SndStreamClient

Returns:
Returns an NSString describing the SndStreamClient.

Reimplemented in SndPlayer, SndPlayer, SndStreamRecorder, and SndStreamRecorder.

streaming thread is shutting down message.

Called just before the streaming thread shuts down, giving a derived client a chance to clean up after itself.

Returns:
Returns self.

streaming thread is shutting down message.

Called just before the streaming thread shuts down, giving a derived client a chance to clean up after itself.

Returns:
Returns self.
- (void) finishStreaming

Tell the client to finish streaming.

Message sent by the manager to tell any clients still connected to it that the manager is about to finish running.

- (void) finishStreaming

Tell the client to finish streaming.

Message sent by the manager to tell any clients still connected to it that the manager is about to finish running.

- (BOOL) generatesOutput

Returns whether the client is an audio-producer (synthesizer, FX)

Returns:
Returns TRUE if the client generates output
- (BOOL) generatesOutput

Returns whether the client is an audio-producer (synthesizer, FX)

Returns:
Returns TRUE if the client generates output
- (id) getPeakLeft: (float *)  leftPeak
right: (float *)  rightPeak 

Get the most recent peak values for the stereo stream.

Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?

Parameters:
leftPeakLeft peak value
rightPeakRigh peak value
Returns:
Returns self.
- (id) getPeakLeft: (float *)  leftPeak
right: (float *)  rightPeak 

Get the most recent peak values for the stereo stream.

Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?

Parameters:
leftPeakLeft peak value
rightPeakRigh peak value
Returns:
Returns self.
Returns:
Returns the number of buffers in the input queue.
Returns:
Returns the number of buffers in the input queue.

Calculates the current input stream latency of the client.

The calculation is determined as the number of buffers pending in the queue waiting to be processed times the buffer duration.

Returns:
Returns latency, in samples.

Calculates the current input stream latency of the client.

The calculation is determined as the number of buffers pending in the queue waiting to be processed times the buffer duration.

Returns:
Returns latency, in samples.

Calculates the current output stream latency of the client.

The calculation is determined as the number of buffers processed in the queue waiting to be played times the buffer duration.

Returns:
Returns latency, in samples.

Calculates the current output stream latency of the client.

The calculation is determined as the number of buffers processed in the queue waiting to be played times the buffer duration.

Returns:
Returns latency, in samples.
- (BOOL) isActive

Returns whether the client is active.

Returns:
Returns a boolean indicating whether the client is active.
- (BOOL) isActive

Returns whether the client is active.

Returns:
Returns a boolean indicating whether the client is active.

Blocks calling thread until outputBuffer is available for locking.

Lock the output buffer before doing anything with it, otherwise the synthesis thread may swap the buffers on you!

Returns:
Returns self.

Blocks calling thread until outputBuffer is available for locking.

Lock the output buffer before doing anything with it, otherwise the synthesis thread may swap the buffers on you!

Returns:
Returns self.
- (BOOL) needsInput

Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)

Returns:
Returns TRUE if the client requires an input stream.
- (BOOL) needsInput

Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)

Returns:
Returns TRUE if the client requires an input stream.
- (id) offlineProcessBuffer: (SndAudioBuffer *)  anAudioBuffer
nowTime: (double)  t 

To come.

Parameters:
anAudioBufferthe audio buffer to process
tnowTime
- (id) offlineProcessBuffer: (SndAudioBuffer *)  anAudioBuffer
nowTime: (double)  t 

To come.

Parameters:
anAudioBufferthe audio buffer to process
tnowTime

Accessor for the currently exposed output buffer.

Don't store the object returned, as the output buffer swaps to the synthesis buffer each processing cycle.

Returns:
Returns the output buffer as a SndAudioBuffer instance.

Accessor for the currently exposed output buffer.

Don't store the object returned, as the output buffer swaps to the synthesis buffer each processing cycle.

Returns:
Returns the output buffer as a SndAudioBuffer instance.
Returns:
Returns the number of buffers in the output queue.
Returns:
Returns the number of buffers in the output queue.

Calculates the stream latency of the client.

The calculation is determined as the total number of buffers in the queue times the buffer duration.

Returns:
Returns latency, in samples.

Calculates the stream latency of the client.

The calculation is determined as the total number of buffers in the queue times the buffer duration.

Returns:
Returns latency, in samples.

Calculates the stream latency of the client.

Number of buffers in queue times buffer duration.

Returns:
Returns latency, in seconds.

Calculates the stream latency of the client.

Number of buffers in queue times buffer duration.

Returns:
Returns latency, in seconds.
- (double) preemptQueuedStream

Any audio buffers which have been processed and awaiting to be retrieved by the SndStreamMixer/SndStreamManager are preempted, clearing any sounds such that any new buffer processed will be mixed without waiting for earlier processed buffers to be mixed.

Returns:
Returns the number of seconds that the stream has been preempted by.

Reimplemented in SndPlayer, and SndPlayer.

- (double) preemptQueuedStream

Any audio buffers which have been processed and awaiting to be retrieved by the SndStreamMixer/SndStreamManager are preempted, clearing any sounds such that any new buffer processed will be mixed without waiting for earlier processed buffers to be mixed.

Returns:
Returns the number of seconds that the stream has been preempted by.

Reimplemented in SndPlayer, and SndPlayer.

Prepare to stream with buffers that look like the supplied buffer.

Called before streaming commences to allow client an opportunity to setup internal generation buffers.

Parameters:
buff
Returns:
Returns self.

Prepare to stream with buffers that look like the supplied buffer.

Called before streaming commences to allow client an opportunity to setup internal generation buffers.

Parameters:
buff
Returns:
Returns self.
- (void) processBuffers

The main synthesis/processing thread method.

A subclass should override this method with its buffer processing method. This should be along the lines of (in pseudo code):

 SndAudioBuffer *b = [self synthBuffer];
 for(i = 0; i < [b length]; i++)
  ([b sample])[i] = a_synth_sample();
 

Reimplemented in SndPlayer, and SndPlayer.

- (void) processBuffers

The main synthesis/processing thread method.

A subclass should override this method with its buffer processing method. This should be along the lines of (in pseudo code):

 SndAudioBuffer *b = [self synthBuffer];
 for(i = 0; i < [b length]; i++)
  ([b sample])[i] = a_synth_sample();
 

Reimplemented in SndPlayer, and SndPlayer.

- (void) resetTime: (double)  originTimeInSeconds

Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.

Parameters:
originTimeInSecondsNew now time.
- (void) resetTime: (double)  originTimeInSeconds

Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.

Parameters:
originTimeInSecondsNew now time.

Moves the synthOutputBuffer onto the processed section of the queue, replacing it with the next empty pending buffer.

This is typically used internally in a SndStreamClient subclass to process multiple output buffers.

Moves the synthOutputBuffer onto the processed section of the queue, replacing it with the next empty pending buffer.

This is typically used internally in a SndStreamClient subclass to process multiple output buffers.

- (void) setAudioProcessorChain: (SndAudioProcessorChain *)  newAudioProcessorChain

Assigns a replacement audio processor chain.

Parameters:
newAudioProcessorChainA SndAudioProcessorChain instance.
- (void) setAudioProcessorChain: (SndAudioProcessorChain *)  newAudioProcessorChain

Assigns a replacement audio processor chain.

Parameters:
newAudioProcessorChainA SndAudioProcessorChain instance.
- (id) setClientName: (NSString *)  name

Sets the client's name.

Useful for identifying clients, especially when debugging - several SndStreamClient warning and error messages will display the name of the client reporting the error.

Parameters:
nameThe client's name.
Returns:
Returns self.
- (id) setClientName: (NSString *)  name

Sets the client's name.

Useful for identifying clients, especially when debugging - several SndStreamClient warning and error messages will display the name of the client reporting the error.

Parameters:
nameThe client's name.
Returns:
Returns self.
- (void) setDelegate: (id)  d

Sets the client's delegate object.

Parameters:
d
Returns:
Returns self.
- (void) setDelegate: (id)  d

Sets the client's delegate object.

Parameters:
d
Returns:
Returns self.
- (id) setDetectPeaks: (BOOL)  detectPeaks

enables / disables peak detection

Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?

Returns:
Returns self.
- (id) setDetectPeaks: (BOOL)  detectPeaks

enables / disables peak detection

Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?

Returns:
Returns self.
- (id) setGeneratesOutput: (BOOL)  b

Determines whether the client's output buffer will be considered for mixing downstream.

Normally you should only need to call this when initializing a derived stream client

Parameters:
bBoolean switch
Returns:
Returns self.
- (id) setGeneratesOutput: (BOOL)  b

Determines whether the client's output buffer will be considered for mixing downstream.

Normally you should only need to call this when initializing a derived stream client

Parameters:
bBoolean switch
Returns:
Returns self.
- (BOOL) setInputBufferCount: (int)  n

Sets the input buffer queue length (only when client is NOT active)

Parameters:
nNumber of buffers
Returns:
TRUE if all is well, FALSE if input buffer length could not be set.
- (BOOL) setInputBufferCount: (int)  n

Sets the input buffer queue length (only when client is NOT active)

Parameters:
nNumber of buffers
Returns:
TRUE if all is well, FALSE if input buffer length could not be set.
- (id) setNeedsInput: (BOOL)  yesOrNo

Sets whether the client requires an input audio stream or not.

Normally you should only need to call this when initializing a subclassed stream client. If true, the stream manager will copy the most recent input buffer into the client's input buffer each processing cycle provided the client hasn't choked the CPU. If the client is running in less than real time, the input buffer is not updated, since the manager must assume that the client's copy of the previous input buffer may still be in use.

Parameters:
yesOrNoYES copy the input buffer into the client.
Returns:
Returns self.
- (id) setNeedsInput: (BOOL)  yesOrNo

Sets whether the client requires an input audio stream or not.

Normally you should only need to call this when initializing a subclassed stream client. If true, the stream manager will copy the most recent input buffer into the client's input buffer each processing cycle provided the client hasn't choked the CPU. If the client is running in less than real time, the input buffer is not updated, since the manager must assume that the client's copy of the previous input buffer may still be in use.

Parameters:
yesOrNoYES copy the input buffer into the client.
Returns:
Returns self.
- (BOOL) setOutputBufferCount: (int)  n

Sets the output buffer queue length (only when client is NOT active)

Parameters:
nNumber of buffers
Returns:
TRUE if all is well, FALSE if output buffer length could not be set.
- (BOOL) setOutputBufferCount: (int)  n

Sets the output buffer queue length (only when client is NOT active)

Parameters:
nNumber of buffers
Returns:
TRUE if all is well, FALSE if output buffer length could not be set.
- (BOOL) startProcessingNextBufferWithInput: (SndAudioBuffer *)  inB
nowTime: (double)  t 

Initiates the generation of the next buffer which will be retrieved by the SndStreamMixer in the next iteration.

SndStreamMixer in it's method -processInBuffer:outBuffer:nowTime: iterates through all its SndStreamClients sending them the message startProcessingNextBufferWithInput:nowTime: after retrieving the SndStreamClient's outputBuffer. This method is responsible for placing the last exposedOutputBuffer onto the pending portion of the output queue (an instance of SndAudioBufferQueue). The exposedOutputBuffer is then retrieved as the next processed buffer using popNextProcessedBuffer.

Parameters:
inBThe Input Buffer. Ignore input buffer if you don't want it.
tThe current now time.
Returns:
Returns YES if able to process the next buffer, NO if the client was disconnected from the SndStreamManager.
- (BOOL) startProcessingNextBufferWithInput: (SndAudioBuffer *)  inB
nowTime: (double)  t 

Initiates the generation of the next buffer which will be retrieved by the SndStreamMixer in the next iteration.

SndStreamMixer in it's method -processInBuffer:outBuffer:nowTime: iterates through all its SndStreamClients sending them the message startProcessingNextBufferWithInput:nowTime: after retrieving the SndStreamClient's outputBuffer. This method is responsible for placing the last exposedOutputBuffer onto the pending portion of the output queue (an instance of SndAudioBufferQueue). The exposedOutputBuffer is then retrieved as the next processed buffer using popNextProcessedBuffer.

Parameters:
inBThe Input Buffer. Ignore input buffer if you don't want it.
tThe current now time.
Returns:
Returns YES if able to process the next buffer, NO if the client was disconnected from the SndStreamManager.
+ (id) streamClient

Factory method to creates and initializes an autoreleased SndStreamClient instance.

Returns:
An autoreleased SndStreamClient object.
+ (id) streamClient

Factory method to creates and initializes an autoreleased SndStreamClient instance.

Returns:
An autoreleased SndStreamClient object.
- (double) streamTime

Return the global (the MANAGER'S) current time.

The manager's sense of time. For most time-operations outside of the synthesis thread, your stream client will probably want the "absolute" stream time as determined by the manager. For example, a client that it told to perform an operation 0.5 seconds in the future must compute the time-till-operation based on the global time; if it were to use the synthesis time, the operation would be performed 0.5 seconds PLUS the synth-ahead latency into the future.

(See synthesisTime)

Returns:
Returns the global (manager) time, in seconds.
- (double) streamTime

Return the global (the MANAGER'S) current time.

The manager's sense of time. For most time-operations outside of the synthesis thread, your stream client will probably want the "absolute" stream time as determined by the manager. For example, a client that it told to perform an operation 0.5 seconds in the future must compute the time-till-operation based on the global time; if it were to use the synthesis time, the operation would be performed 0.5 seconds PLUS the synth-ahead latency into the future.

(See synthesisTime)

Returns:
Returns the global (manager) time, in seconds.
- (double) synthesisTime

Return the client's current SYNTHESIS time.

The client synthesis thread's sense of time. Since the client's synthesis (processing) thread can process several buffers ahead of the manager, the client must maintain an independent sense of time. This is the time your derived stream client class MUST use inside its processBuffers overridden method.

NOTE - This means all operations must be fed to a stream client thread with a look-ahead delta time greater or equal to the process-ahead latency to ensure correct timing.

(See streamTime)

Returns:
Returns the synthesis thread time, in seconds.
- (double) synthesisTime

Return the client's current SYNTHESIS time.

The client synthesis thread's sense of time. Since the client's synthesis (processing) thread can process several buffers ahead of the manager, the client must maintain an independent sense of time. This is the time your derived stream client class MUST use inside its processBuffers overridden method.

NOTE - This means all operations must be fed to a stream client thread with a look-ahead delta time greater or equal to the process-ahead latency to ensure correct timing.

(See streamTime)

Returns:
Returns the synthesis thread time, in seconds.

Accessor for the current input buffer.

Returns:
Returns the input buffer member

Accessor for the current input buffer.

Returns:
Returns the input buffer member

Accessor for the current synthesis buffer.

This is typically used internally in a SndStreamClient subclass to retrieve the current buffer to be processed.

Returns:
Returns the buffer to be synthesized as a SndAudioBuffer instance.

Accessor for the current synthesis buffer.

This is typically used internally in a SndStreamClient subclass to retrieve the current buffer to be processed.

Returns:
Returns the buffer to be synthesized as a SndAudioBuffer instance.

Releases lock on the outputBuffer.

Returns:
Returns self.

Releases lock on the outputBuffer.

Returns:
Returns self.
- (id) welcomeClientWithInputBuffer: (SndAudioBuffer *)  inputBuffer
outputBuffer: (SndAudioBuffer *)  outputBuffer
manager: (SndStreamManager *)  streamManager 

Initialize the client with a buffer showing manager format and start its thread.

Each SndStreamClient instance receives welcomeClientWithInputBuffer:outputBuffer:manager: message from SndStreamManager when the client is first added to the manager. The receiving instance is supplied the first output buffer to use. This method prepares input and/or output queues as needed then initiates one thread per stream client. The SndStreamClient method processingThread is executed by that thread.

Parameters:
inputBufferThe buffer to use for as a prototype for input SndAudioBufferQueues.
outputBufferThe buffer to use for output and as a prototype for output SndAudioBufferQueues.
streamManagerThe SndStreamManager responsible for this client.
Returns:
Returns self
- (id) welcomeClientWithInputBuffer: (SndAudioBuffer *)  inputBuffer
outputBuffer: (SndAudioBuffer *)  outputBuffer
manager: (SndStreamManager *)  streamManager 

Initialize the client with a buffer showing manager format and start its thread.

Each SndStreamClient instance receives welcomeClientWithInputBuffer:outputBuffer:manager: message from SndStreamManager when the client is first added to the manager. The receiving instance is supplied the first output buffer to use. This method prepares input and/or output queues as needed then initiates one thread per stream client. The SndStreamClient method processingThread is executed by that thread.

Parameters:
inputBufferThe buffer to use for as a prototype for input SndAudioBufferQueues.
outputBufferThe buffer to use for output and as a prototype for output SndAudioBufferQueues.
streamManagerThe SndStreamManager responsible for this client.
Returns:
Returns self

Member Data Documentation

- (BOOL) active [protected]

When YES, the client is actively processing streamed audio. When NO the client thread is not running.

- (NSString *) clientName [protected]

The descriptive name of the client.

- (double) clientNowTime [protected]

The clients sense of time as used by subclasses for synthesis.

- (id) delegate [protected]

The delegate to receive messages from the client.

The buffer in the output queue retrieved by the SndStreamMixer (driven by the output thread).

- (BOOL) generatesOutput [protected]

Indicates this client generates audio output data, retrieved from this client using -?

- (SndAudioBufferQueue *) inputQueue [protected]

A FIFO queue of SndAudioBuffers holding those pending input and those processed.

- (double) lastManagerTime [protected]

The last time received from the calling SndStreamManager. When streaming to non-interleaved buffers time does not monotonically advance. We check that using this.

- (SndStreamManager *) manager [protected]

The stream clients manager.

- (NSConditionLock *) managerConnectionLock [protected]

Controls the connection and disconnection of the client from it's manager, when the client's processing thread ends. This guards against racing releasing the client.

- (BOOL) needsInput [protected]

Indicates this client processes audio data received from a SndStreamMixer instance by -startProcessingNextBufferWithInput:nowTime:

- (NSConditionLock *) outputBufferLock [protected]

Controls access to the output buffer, particularly when changing the exposedOutputBuffer.

- (SndAudioBufferQueue *) outputQueue [protected]

A FIFO queue of SndAudioBuffers holding those pending output and those processed.

A chain of SndAudioProcessors processing this stream clients output.

- (SndAudioBuffer *) synthInputBuffer [protected]

The buffer in the input queue currently ready for retrieval.

- (SndAudioBuffer *) synthOutputBuffer [protected]

The buffer in the output queue modified by the synthesis thread.

- (NSConditionLock *) synthThreadLock [protected]

Controls access to the output queue, particularly when changing the synthOutputBuffer.


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