uk.org.toot.audio.server
Class NonRealTimeAudioServer

java.lang.Object
  extended by uk.org.toot.audio.server.NonRealTimeAudioServer
All Implemented Interfaces:
java.lang.Runnable, AudioClient, AudioServer

public class NonRealTimeAudioServer
extends java.lang.Object
implements AudioServer, AudioClient, java.lang.Runnable

An AudioServer that decorates any other AudioServer to add a non-real-time capability.


Field Summary
 
Fields inherited from interface uk.org.toot.audio.server.AudioServer
THREAD_NAME
 
Constructor Summary
NonRealTimeAudioServer(AudioServer server)
           
 
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 isRealTime()
           
 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 run()
          Public as an implementation side-effect.
 void setClient(AudioClient client)
          Sets the single AudioClient.
 void setEnabled(boolean enable)
          When not enabled, work() may not be called and should be ignored if it is called.
 void setRealTime(boolean rt)
           
 void start()
          Requests that the server starts if possible, otherwise actual start will be deferred until it is possible.
 void stop()
          Stops the server.
 void work(int nFrames)
          Override this method to synchronise with non-real-time timing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonRealTimeAudioServer

public NonRealTimeAudioServer(AudioServer server)
Method Detail

setRealTime

public void setRealTime(boolean rt)

isRealTime

public boolean isRealTime()

start

public void start()
Description copied from interface: AudioServer
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.

Specified by:
start in interface AudioServer

stop

public void stop()
Description copied from interface: AudioServer
Stops the server.

Specified by:
stop in interface AudioServer

setClient

public void setClient(AudioClient client)
Description copied from interface: AudioServer
Sets the single AudioClient. Use CompoundAudioClient for multiple client support. Typically start may be deferred until called at least once.

Specified by:
setClient in interface AudioServer

isRunning

public boolean isRunning()
Description copied from interface: AudioServer
Returns whether running. i.e. started but not stopped. Contract is that AudioClient.work(int nFrames) must be called when true.

Specified by:
isRunning in interface AudioServer

getLoad

public float getLoad()
Specified by:
getLoad in interface AudioServer
Returns:
the normalised server load 0..1f

setEnabled

public void setEnabled(boolean enable)
Description copied from interface: AudioClient
When not enabled, work() may not be called and should be ignored if it is called.

Specified by:
setEnabled in interface AudioClient

work

public void work(int nFrames)
Override this method to synchronise with non-real-time timing

Specified by:
work in interface AudioClient
Parameters:
nFrames - the number of frames to be processed

run

public void run()
Public as an implementation side-effect. Override this method to completely take over non-real-time timing on the existing non-real-time thread.

Specified by:
run in interface java.lang.Runnable

createAudioBuffer

public AudioBuffer createAudioBuffer(java.lang.String name)
Specified by:
createAudioBuffer in interface AudioServer

getAvailableOutputNames

public java.util.List<java.lang.String> getAvailableOutputNames()
Specified by:
getAvailableOutputNames in interface AudioServer

getAvailableInputNames

public java.util.List<java.lang.String> getAvailableInputNames()
Specified by:
getAvailableInputNames in interface AudioServer

openAudioOutput

public IOAudioProcess openAudioOutput(java.lang.String name,
                                      java.lang.String label)
                               throws java.lang.Exception
Description copied from interface: AudioServer
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.

Specified by:
openAudioOutput in interface AudioServer
Throws:
java.lang.Exception

openAudioInput

public IOAudioProcess openAudioInput(java.lang.String name,
                                     java.lang.String label)
                              throws java.lang.Exception
Description copied from interface: AudioServer
Returns an AudioProcess backed by a hardware audio input line represented by 'name' and labelled 'label'.

Specified by:
openAudioInput in interface AudioServer
Throws:
java.lang.Exception

closeAudioOutput

public void closeAudioOutput(IOAudioProcess output)
Specified by:
closeAudioOutput in interface AudioServer

closeAudioInput

public void closeAudioInput(IOAudioProcess input)
Specified by:
closeAudioInput in interface AudioServer

getSampleRate

public float getSampleRate()
Specified by:
getSampleRate in interface AudioServer

getInputLatencyFrames

public int getInputLatencyFrames()
Specified by:
getInputLatencyFrames in interface AudioServer
Returns:
the number of frames input latency due to software and hardware.

getOutputLatencyFrames

public int getOutputLatencyFrames()
Specified by:
getOutputLatencyFrames in interface AudioServer
Returns:
the number of frames output latency due to software and hardware.

getTotalLatencyFrames

public int getTotalLatencyFrames()
Specified by:
getTotalLatencyFrames in interface AudioServer
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.