public class AudioContext
extends java.lang.Object
IOAudioFormat used,
the IO device, the audio buffer size and the system IO buffer size. An
AudioContext also provides a UGen called out, which is
the output point for networks of UGens in a Beads project.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE |
Gain |
out
The root
UGen. |
| Constructor and Description |
|---|
AudioContext()
This constructor creates the default AudioContext, which means net.beadsproject.beads.core.io.JavaSoundAudioIO if it can find it, or net.beadsproject.beads.core.io.NonrealtimeIO otherwise.
|
AudioContext(AudioIO ioSystem)
Creates a new AudioContext with default audio format and
buffer size and the specified
AudioIO. |
AudioContext(AudioIO ioSystem,
int bufferSizeInFrames)
Creates a new AudioContext with default audio format and the specified
buffer size and
AudioIO. |
AudioContext(AudioIO ioSystem,
int bufferSizeInFrames,
IOAudioFormat audioFormat)
Creates a new AudioContext with the specified buffer size, AudioIO and audio format.
|
AudioContext(int bufferSize)
This constructor creates the default AudioContext, which means net.beadsproject.beads.core.io.JavaSoundAudioIO if it can find it, or net.beadsproject.beads.core.io.NonrealtimeIO otherwise.
|
| Modifier and Type | Method and Description |
|---|---|
static IOAudioFormat |
defaultAudioFormat(int inputs,
int outputs)
Generates the default
IOAudioFormat for AudioContext, with the
given number of channels. |
TimeStamp |
generateTimeStamp(int index)
Generates a TimeStamp with the current time step and the given index into
the time step.
|
IOAudioFormat |
getAudioFormat()
Gets the AudioFormat for this AudioContext.
|
IOAudioFormat |
getAudioFormat(int inputs,
int outputs)
Generates a new AudioFormat with the same everything as the
AudioContext's AudioFormat except for the number of channels.
|
UGen |
getAudioInput()
Returns a UGen which can be used to grab audio from the audio input, as
specified by the AudioIO.
|
UGen |
getAudioInput(int[] channels)
Returns a UGen which can be used to grab audio from the audio input, as
specified by the AudioIO.
|
AudioIO |
getAudioIO() |
float[] |
getBuf()
Gets a buffer from the buffer reserve.
|
int |
getBufferSize()
Gets the buffer size for this AudioContext.
|
float[] |
getCleanBuf()
Gets a zero initialised buffer from the buffer reserve.
|
float |
getSampleRate()
Gets the sample rate for this AudioContext.
|
double |
getTime()
Get the runtime (in ms) since starting.
|
long |
getTimeStep()
Gets the current time step of this AudioContext.
|
float[] |
getZeroBuf()
Gets a pointer to a buffer of length bufferSize, full of zeros.
|
AudioContext |
invokeAfterEveryFrame(Bead target)
Queues the specified Bead to be messaged after every audio frame.
|
AudioContext |
invokeAfterFrame(Bead target)
Queues the specified Bead to be messaged upon the next audio frame
completion.
|
AudioContext |
invokeBeforeEveryFrame(Bead target)
Queues the specified Bead to be messaged before every audio frame.
|
AudioContext |
invokeBeforeFrame(Bead target)
Queues the specified bead to be messaged before the next audio frame.
|
boolean |
isRunning()
Checks if this AudioContext is running.
|
void |
logTime(boolean logTime)
Switch on/off logging of time when running in realtime.
|
double |
msToSamples(double msTime)
Converts samples to milliseconds at the current sample rate.
|
void |
postAudioFormatInfo()
Prints AudioFormat information to System.out.
|
void |
printCallChain()
Prints the entire call chain to System.out (equivalent to
AudioContext.printCallChain(this.out, 0);)
|
static void |
printCallChain(UGen current,
int depth)
Prints a representation of the audio signal chain stemming upwards from
the specified UGen to System.out, indented by the specified depth.
|
void |
quickie(UGen ugen)
Convenience method to quickly audition a
UGen. |
void |
record(double timeMS,
java.lang.String filename)
Tells the AudioContext to record all output for the given millisecond
duration, kill the AudioContext, and save the recording to the given file
path.
|
void |
reset()
Simply resets the timeStep to zero.
|
void |
runForNMillisecondsNonRealTime(double n)
Runs the AudioContext in non-realtime for n milliseconds (that's n
non-realtime milliseconds).
|
void |
runNonRealTime()
Starts the AudioContext running in non-realtime.
|
double |
samplesToMs(double sampleTime)
Converts milliseconds to samples at the current sample rate.
|
void |
start()
Starts the AudioContext running in realtime.
|
void |
stop()
Stops the AudioContext if running either in realtime or non-realtime.
|
boolean |
stopInvokingAfterEveryFrame(Bead target)
Removes the specified Bead from the list of Beads that are messaged after
every audio frame.
|
boolean |
stopInvokingBeforeEveryFrame(Bead target)
Removes the specified Bead from the list of Beads that are messaged
before every audio frame.
|
protected void |
update()
callback from AudioIO.
|
public static final int DEFAULT_BUFFER_SIZE
public AudioContext()
public AudioContext(int bufferSize)
bufferSize - the number of samples calculated during one frame of audio processing. Higher numbers mean more latency and more stability. Typically use powers of 2. Default is 512.public AudioContext(AudioIO ioSystem)
AudioIO. The default audio format is 44.1Khz,
16 bit, stereo, signed, bigEndian.ioSystem - the AudioIO system.public AudioContext(AudioIO ioSystem, int bufferSizeInFrames)
AudioIO. The default audio format is 44.1Khz,
16 bit, stereo, signed, bigEndian.bufferSizeInFrames - the buffer size in samples.ioSystem - the AudioIO system.public AudioContext(AudioIO ioSystem, int bufferSizeInFrames, IOAudioFormat audioFormat)
bufferSizeInFrames - the buffer size in samples.ioSystem - the AudioIO system.audioFormat - the audio format, which specifies sample rate, bit depth,
number of channels, signedness and byte order.public UGen getAudioInput(int[] channels)
channels - an array of ints indicating which channels are required.public UGen getAudioInput()
getAudioInput(int[]).protected void update()
public float[] getBuf()
public float[] getCleanBuf()
public float[] getZeroBuf()
getCleanBuf().public void runNonRealTime()
public void runForNMillisecondsNonRealTime(double n)
n - number of milliseconds.public int getBufferSize()
public float getSampleRate()
public IOAudioFormat getAudioFormat()
public IOAudioFormat getAudioFormat(int inputs, int outputs)
numChannels - the number of channels.public static IOAudioFormat defaultAudioFormat(int inputs, int outputs)
IOAudioFormat for AudioContext, with the
given number of channels. The default values are: sampleRate=44100,
sampleSizeInBits=16, signed=true, bigEndian=true.numChannels - the number of channels to use.public void postAudioFormatInfo()
public static void printCallChain(UGen current, int depth)
current - UGen to start from.depth - depth by which to indent.public void printCallChain()
public double msToSamples(double msTime)
msTime - duration in milliseconds.public double samplesToMs(double sampleTime)
sampleTime - number of samples.public long getTimeStep()
public TimeStamp generateTimeStamp(int index)
index - the index into the current time step.public double getTime()
public void logTime(boolean logTime)
logTime - set true to log time.public void record(double timeMS,
java.lang.String filename)
throws java.lang.Exception
public void quickie(UGen ugen)
UGen.ugen - the UGen to audition.public void start()
public void reset()
public void stop()
public boolean isRunning()
public AudioIO getAudioIO()
public AudioContext invokeAfterFrame(Bead target)
target - The Bead to message.public AudioContext invokeAfterEveryFrame(Bead target)
target - The Bead to message.public boolean stopInvokingAfterEveryFrame(Bead target)
target - The Bead to stop messaging.public AudioContext invokeBeforeFrame(Bead target)
target - The Bead to message.public AudioContext invokeBeforeEveryFrame(Bead target)
target - The Bead to message.public boolean stopInvokingBeforeEveryFrame(Bead target)
target - The Bead to stop messaging.