SndStreamManager Class Reference

Provides client connection and stream mixing services, and acts as the gateway to the lowlevel MKPerformSndMIDI C functions. More...

#import <SndStreamManager.h>

Inherits SndDelegateMessagePassing-p.

List of all members.

Public Member Functions

(NSString *) - description
 Returns an NSString with description of SndStreamManager.
(void) - startStreaming
 Starts streaming.
(void) - stopStreaming
 Stops streaming.
(void) - streamStartStopThread
 a very lightweight thread used for starting and stopping the audio streams
(void) - delegateMessageThread:
 A very lightweight thread used for sending delegate messages from the background threads to the main thread.
(BOOL) - addClient:
 Adds an SndStreamClient to the manager's mixer.
(BOOL) - removeClient:
 Removes the SndStreamClient from the manager's mixer.
(void) - processStreamAtTime:input:output:
 Passes new input and output buffers from the underlying API to the mixer.
(id) - setFormat:
 Sets the format to be used during streaming.
(SndFormat- format
 Returns the format to be used during streaming.
(double) - nowTime
 Return the current time as understood by the SndStreamManager.
(SndStreamMixer *) - mixer
 Mixer member accessor method.
(BOOL) - isActive
 indicates whether streaming is happening (active)
(double) - samplingRate
(void) - resetTime:
 Resets the global stream time to originTimeInSeconds.
(void) - sendMessageInMainThreadToTarget:sel:arg1:arg2:
 Sends messages from any thread to any object in the main thread.

Static Public Member Functions

(SndStreamManager *) + defaultStreamManager
 Accessor to the default stream manager created upon class initialization.
(NSArray *) + getDriverNames
 Returns an NSArray of NSStrings listing the sound drivers available.


Detailed Description

Provides client connection and stream mixing services, and acts as the gateway to the lowlevel MKPerformSndMIDI C functions.

Each SndStreamManager has a SndStreamMixer which has a SndAudioProcessorChain which has a SndAudioFader. Adding clients to a manager adds them to the underlying mixer.


Member Function Documentation

+ (SndStreamManager *) defaultStreamManager  

Accessor to the default stream manager created upon class initialization.

SndStreamClients will usually connect to the default stream manager, unless the user wishes to explicitly create their own manager.

Returns:
Returns the default manager

+ (NSArray *) getDriverNames  

Returns an NSArray of NSStrings listing the sound drivers available.

The format of the names is dependent on the underlying operating system.

- (NSString *) description  

Returns an NSString with description of SndStreamManager.

Returns:
Returns an NSString with description of SndStreamManager

- (void) startStreaming  

Starts streaming.

You should never need to call this. Streaming is started automatically when the first client connects to the manager.

- (void) stopStreaming  

Stops streaming.

You should never need to call this. Streaming is stopped automatically when the last client disconnects from the manager.

- (void) streamStartStopThread  

a very lightweight thread used for starting and stopping the audio streams

You should never need to call this. The manager can instruct the starting and stopping of streams by setting bg_sem to BG_startNow or BG_stopNow, and setting the bg_threadLock condition. The thread is created on this method when a stream is to begin, if it does not exist already.

- (void) delegateMessageThread: (NSArray *)  ports  

A very lightweight thread used for sending delegate messages from the background threads to the main thread.

Parameters:
ports A pair of NSPorts in an NSArray, used for setting up the distributed object between this thread and the main thread.
You should never need to call this. The manager calls this method as it starts up (in init) then the thread just sits there waiting for a signal to say that there's a delegate message sitting in an array, waiting to be sent. The delegate message should have been sent to -sendMessageInMainThreadToTarget:sel:arg1:arg2:. After arriving in the delegate message thread it is dispatched to the main thread via Distributed Objects, and will be sent on to the requested delegate at the next convenient time in the NSRunLoop.

- (BOOL) addClient: (SndStreamClient *)  client  

Adds an SndStreamClient to the manager's mixer.

If the SndStreamClient is already a client of the mixer, it is NOT added again. If the client is the first connected to the manager, the manager will automatically start streaming.

Parameters:
client The SndStreamClient instance to begin managing and mixing.
Returns:
TRUE if client was successfully added, FALSE if the client is already registered, or the audio device couldn't start streaming.

- (BOOL) removeClient: (SndStreamClient *)  client  

Removes the SndStreamClient from the manager's mixer.

If the removed client was the last client connected to the manager, streaming will be automatically shut down.

Parameters:
client The client to be disconnected from the manager.
Returns:
TRUE if the client was successfully removed.

- (void) processStreamAtTime: (double)  sampleCount
input: (SndAudioBuffer *)  inB
output: (SndAudioBuffer *)  outB 

Passes new input and output buffers from the underlying API to the mixer.

Do not call this method - it is part of the audio callback handler.

Parameters:
sampleCount Time in samples
inB inputBuffer
outB 

- (id) setFormat: (SndFormat newFormat  

Sets the format to be used during streaming.

Do not call this method - it is called as part of the start-streaming process. The stream format used is the native format coming up from the devices below.

Parameters:
newFormat A SndFormat structure.
Returns:
Returns self.

- (SndFormat) format  

Returns the format to be used during streaming.

Returns:
Returns a SndFormat structure.

- (double) nowTime  

Return the current time as understood by the SndStreamManager.

Returns:
nowTime as a double

- (SndStreamMixer *) mixer  

Mixer member accessor method.

Returns:
The internal SndStreamMixer

- (BOOL) isActive  

indicates whether streaming is happening (active)

Returns:
TRUE if streaming is active

- (double) samplingRate  

Returns:
The streaming sampling rate.

- (void) resetTime: (double)  originTimeInSeconds  

Resets the global stream time to originTimeInSeconds.

Parameters:
originTimeInSeconds New origin time, in seconds.
The new origin time is propagated to the mixer, and thus to the stream clients.

- (void) sendMessageInMainThreadToTarget: (id)  target
sel: (SEL)  sel
arg1: (id)  arg1
arg2: (id)  arg2 

Sends messages from any thread to any object in the main thread.

This method was introduced to allow easy delegate messaging from the underlying audio threads, but can be used by any object. The method creates an NSInvocation out of the parameters given, and adds it to an array of waiting messages. Then a background thread with an NSConnection to the main thread is notified, and the messages are passed up the connection one by one, and dispatched in the main thread. Note that the final dispatch is only done as part of the application's NSRunLoop, which means that if the main thread is busy doing anything, it can tke a little while for the delegate message to appear. Even if this is the case, this method should not block for long.

Parameters:
target id target object
sel SEL the selector to be sent, eg @selector(description:withObject:)
arg1 the first argument in the selector
arg2 the second argument in the selector


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

Generated on Sat Dec 5 17:01:16 2009 for MusicKit by  doxygen 1.5.6