uk.org.toot.audio.server
Interface AudioServer

All Known Implementing Classes:
AbstractAudioServerDecorator, MultiIOAudioServer, NonRealTimeAudioServer

public interface AudioServer

An AudioServer represents the single thread of time and is responsible for separating other code from the concerns of timing and hardware i/o. The timing concern is seperated with setClient(), the server should call work() on the currently set client when it isRunning(), synchronously with hardware i/o. The server can be started with start() and stopped with stop(). Also, createAudioBuffer() returns an AudioBuffer suitable for use with the particular timing, it is assumed that work() is called at regular intervals for which the buffer size is appropriate. The server should synchronously resize buffers if the implicit timing is changed. The hardware i/o is abstracted with getAvailableOutputNames() and getAvailableInputNames() to discover the names of hardware output and input lines respectively. The first line returned should be the most obvious stereo line. Stereo lines should be returned before mono lines. Also, createAudioOutput() and createAudioInput() create AudioProcess's backed by named hardware lines with user specified labels. An AudioServer implementation should use a particular audio format, defined in its own terms, to return appropriate AudioBuffers and IOAudioProcesses. Latency occurs in hardware and software for both input and output. Total latency from analogue input to analogue output is Hardware Input + Software Input + Software Output + Hardware Output


Field Summary
static java.lang.String THREAD_NAME
           
 
Method Summary
 void closeAudioInput(IOAudioProcess input)
           
 void closeAudioOutput(IOAudioProcess output)
           
 AudioBuffer createAudioBuffer(java.lang.String name)
           
 java.util.List<java.lang.String> getAvailableInputNames()
           
 java.util.List<java.lang.String> getAvailableOutputNames()
           
 int getInputLatencyFrames()
           
 float getLoad()
           
 int getOutputLatencyFrames()
           
 float getSampleRate()
           
 int getTotalLatencyFrames()
           
 boolean isRunning()
          Returns whether running.
 IOAudioProcess openAudioInput(java.lang.String name, java.lang.String label)
          Returns an AudioProcess backed by a hardware audio input line represented by 'name' and labelled 'label'.
 IOAudioProcess openAudioOutput(java.lang.String name, java.lang.String label)
          Returns an AudioProcess backed by a hardware audio output line represented by 'name' and labelled 'label'.
 void setClient(AudioClient client)
          Sets the single AudioClient.
 void start()
          Requests that the server starts if possible, otherwise actual start will be deferred until it is possible.
 void stop()
          Stops the server.
 

Field Detail

THREAD_NAME

static final java.lang.String THREAD_NAME
See Also:
Constant Field Values
Method Detail

start

void start()
Requests that the server starts if possible, otherwise actual start will be deferred until it is possible. Typically start may become possible after a setClient call and potentially one or more createAudioOutput or createAudioInput calls.


stop

void stop()
Stops the server.


isRunning

boolean isRunning()
Returns whether running. i.e. started but not stopped. Contract is that AudioClient.work(int nFrames) must be called when true.


setClient

void setClient(AudioClient client)
Sets the single AudioClient. Use CompoundAudioClient for multiple client support. Typically start may be deferred until called at least once.


getAvailableOutputNames

java.util.List<java.lang.String> getAvailableOutputNames()

getAvailableInputNames

java.util.List<java.lang.String> getAvailableInputNames()

openAudioOutput

IOAudioProcess openAudioOutput(java.lang.String name,
                               java.lang.String label)
                               throws java.lang.Exception
Returns an AudioProcess backed by a hardware audio output line represented by 'name' and labelled 'label'. start may be deferred until called at least once.

Throws:
java.lang.Exception

openAudioInput

IOAudioProcess openAudioInput(java.lang.String name,
                              java.lang.String label)
                              throws java.lang.Exception
Returns an AudioProcess backed by a hardware audio input line represented by 'name' and labelled 'label'.

Throws:
java.lang.Exception

closeAudioOutput

void closeAudioOutput(IOAudioProcess output)

closeAudioInput

void closeAudioInput(IOAudioProcess input)

createAudioBuffer

AudioBuffer createAudioBuffer(java.lang.String name)

getSampleRate

float getSampleRate()

getLoad

float getLoad()
Returns:
the normalised server load 0..1f

getInputLatencyFrames

int getInputLatencyFrames()
Returns:
the number of frames input latency due to software and hardware.

getOutputLatencyFrames

int getOutputLatencyFrames()
Returns:
the number of frames output latency due to software and hardware.

getTotalLatencyFrames

int getTotalLatencyFrames()
Returns:
the number of frames latency for inputs and outputs due to both hardware and software.


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.