MusicKit
0.0.0
|
A stream client is responsible for audio streaming, signal processing and synthesis. More...
#import <SndStreamClient.h>
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 | |
SndAudioBuffer * | exposedOutputBuffer |
SndAudioBuffer * | synthOutputBuffer |
SndAudioBuffer * | synthInputBuffer |
SndAudioBufferQueue * | outputQueue |
SndAudioBufferQueue * | inputQueue |
NSConditionLock * | synthThreadLock |
NSConditionLock * | outputBufferLock |
NSConditionLock * | managerConnectionLock |
BOOL | active |
BOOL | needsInput |
BOOL | generatesOutput |
SndAudioProcessorChain * | processorChain |
SndStreamManager * | manager |
id | delegate |
double | clientNowTime |
double | lastManagerTime |
NSString * | clientName |
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.
Returns the client's SndAudioProcessorChain.
Returns the client's SndAudioProcessorChain.
- (NSString *) clientName |
Accessor to the client name.
- (NSString *) clientName |
Accessor to the client name.
- (id) delegate |
Accessor method to the delegate member.
- (id) delegate |
Accessor method to the delegate member.
- (NSString *) description |
Describes SndStreamClient.
Describes SndStreamClient
Reimplemented in SndPlayer, SndPlayer, SndStreamRecorder, and SndStreamRecorder.
- (NSString *) description |
Describes SndStreamClient.
Describes SndStreamClient
Reimplemented in SndPlayer, SndPlayer, SndStreamRecorder, and SndStreamRecorder.
- (id) didFinishStreaming |
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.
- (id) didFinishStreaming |
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.
- (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)
- (BOOL) generatesOutput |
Returns whether the client is an audio-producer (synthesizer, FX)
- (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?
leftPeak | Left peak value |
rightPeak | Righ peak value |
- (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?
leftPeak | Left peak value |
rightPeak | Righ peak value |
- (int) inputBufferCount |
- (int) inputBufferCount |
- (long) instantaneousInputLatencyInSamples |
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.
- (long) instantaneousInputLatencyInSamples |
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.
- (long) instantaneousOutputLatencyInSamples |
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.
- (long) instantaneousOutputLatencyInSamples |
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.
- (BOOL) isActive |
Returns whether the client is active.
- (BOOL) isActive |
Returns whether the client is active.
- (id) lockOutputBuffer |
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!
- (id) lockOutputBuffer |
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!
- (BOOL) needsInput |
Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)
- (BOOL) needsInput |
Returns whether the client is an audio-consumer (recorder, FX, signal analyzer)
- (id) offlineProcessBuffer: | (SndAudioBuffer *) | anAudioBuffer | |
nowTime: | (double) | t | |
To come.
anAudioBuffer | the audio buffer to process |
t | nowTime |
- (id) offlineProcessBuffer: | (SndAudioBuffer *) | anAudioBuffer | |
nowTime: | (double) | t | |
To come.
anAudioBuffer | the audio buffer to process |
t | nowTime |
- (SndAudioBuffer *) outputBuffer |
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.
- (SndAudioBuffer *) outputBuffer |
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.
- (int) outputBufferCount |
- (int) outputBufferCount |
- (long) outputLatencyInSamples |
Calculates the stream latency of the client.
The calculation is determined as the total number of buffers in the queue times the buffer duration.
- (long) outputLatencyInSamples |
Calculates the stream latency of the client.
The calculation is determined as the total number of buffers in the queue times the buffer duration.
- (double) outputLatencyInSeconds |
Calculates the stream latency of the client.
Number of buffers in queue times buffer duration.
- (double) outputLatencyInSeconds |
Calculates the stream latency of the client.
Number of buffers in queue times buffer duration.
- (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.
- (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.
- (id) prepareToStreamWithBuffer: | (SndAudioBuffer *) | buff |
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.
buff |
- (id) prepareToStreamWithBuffer: | (SndAudioBuffer *) | buff |
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.
buff |
- (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();
- (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();
- (void) resetTime: | (double) | originTimeInSeconds |
Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.
originTimeInSeconds | New now time. |
- (void) resetTime: | (double) | originTimeInSeconds |
Sets the clients sense of streamTime. Internal clientNowTime is recalculated relative to the new Time.
originTimeInSeconds | New now time. |
- (void) rotateSynthOutputBuffer |
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) rotateSynthOutputBuffer |
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.
newAudioProcessorChain | A SndAudioProcessorChain instance. |
- (void) setAudioProcessorChain: | (SndAudioProcessorChain *) | newAudioProcessorChain |
Assigns a replacement audio processor chain.
newAudioProcessorChain | A 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.
name | The client's name. |
- (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.
name | The client's name. |
- (void) setDelegate: | (id) | d |
Sets the client's delegate object.
d |
- (void) setDelegate: | (id) | d |
Sets the client's delegate object.
d |
- (id) setDetectPeaks: | (BOOL) | detectPeaks |
enables / disables peak detection
Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?
- (id) setDetectPeaks: | (BOOL) | detectPeaks |
enables / disables peak detection
Not implemented yet - not convinced this should be here - maybe inside an SndAudioProcessor?
- (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
b | Boolean switch |
- (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
b | Boolean switch |
- (BOOL) setInputBufferCount: | (int) | n |
Sets the input buffer queue length (only when client is NOT active)
n | Number of buffers |
- (BOOL) setInputBufferCount: | (int) | n |
Sets the input buffer queue length (only when client is NOT active)
n | Number of buffers |
- (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.
yesOrNo | YES copy the input buffer into the client. |
- (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.
yesOrNo | YES copy the input buffer into the client. |
- (BOOL) setOutputBufferCount: | (int) | n |
Sets the output buffer queue length (only when client is NOT active)
n | Number of buffers |
- (BOOL) setOutputBufferCount: | (int) | n |
Sets the output buffer queue length (only when client is NOT active)
n | Number of buffers |
- (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.
inB | The Input Buffer. Ignore input buffer if you don't want it. |
t | The current now time. |
- (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.
inB | The Input Buffer. Ignore input buffer if you don't want it. |
t | The current now time. |
+ (id) streamClient |
Factory method to creates and initializes an autoreleased SndStreamClient instance.
+ (id) streamClient |
Factory method to creates and initializes an autoreleased SndStreamClient instance.
- (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
)
- (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
)
- (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
)
- (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
)
Accessor for the current input buffer.
Accessor for the current input buffer.
Accessor for the current synthesis buffer.
This is typically used internally in a SndStreamClient subclass to retrieve the current buffer to be processed.
Accessor for the current synthesis buffer.
This is typically used internally in a SndStreamClient subclass to retrieve the current buffer to be processed.
- (id) unlockOutputBuffer |
Releases lock on the outputBuffer.
- (id) unlockOutputBuffer |
Releases lock on the outputBuffer.
- (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.
inputBuffer | The buffer to use for as a prototype for input SndAudioBufferQueues. |
outputBuffer | The buffer to use for output and as a prototype for output SndAudioBufferQueues. |
streamManager | The SndStreamManager responsible for this client. |
- (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.
inputBuffer | The buffer to use for as a prototype for input SndAudioBufferQueues. |
outputBuffer | The buffer to use for output and as a prototype for output SndAudioBufferQueues. |
streamManager | The SndStreamManager responsible for this client. |
- (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.
- (SndAudioBuffer *) exposedOutputBuffer [protected] |
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.
- (SndAudioProcessorChain *) processorChain [protected] |
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.