public abstract class Graph extends Object
Unless specifically noted, methods in this class are not thread-safe, and should only be called on the audio thread.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Graph.Dependent
An interface for types that can be attached to a Graph and will be called
before every new buffer is processed.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Graph()
Base Graph constructor for graph with default 2 channels of audio input
and output.
|
protected |
Graph(int inputCount,
int outputCount)
Base Graph constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Add |
add()
Create an
Add Pipe. |
protected Add |
add(Pipe... ugens)
Create an
Add Pipe, and add the provided Pipes as inputs to it. |
protected void |
addDependent(Graph.Dependent dependent)
Add a
Graph.Dependent to the graph. |
int |
blockSize()
Query the audio block size / size of each processed buffer.
|
protected Fn |
fn(DoubleUnaryOperator function)
Create a
Fn Pipe that applies the given operation to every
sample. |
protected Pipe |
in(int index)
Access the Pipe for the specified input channel.
|
protected abstract void |
init()
Method called to initialize the audio graph.
|
void |
invokeLater(Runnable task)
Add a task to be run on the audio thread before the next buffer is
processed.
|
protected Pipe |
link(Pipe... ugens)
Link the provided list of units (Pipes) together.
|
protected double |
midiToFrequency(int midi)
Convert the given MIDI note number into its frequency in Hz.
|
long |
millis()
Query the time in milliseconds, based on the sample playback clock.
|
protected Mod |
mod()
Create a
Mod pipe. |
protected Mod |
mod(Pipe... ugens)
Create a
Mod pipe, and add the provided Pipes as inputs to it. |
protected Mod |
modFn(DoubleBinaryOperator function)
Create a
Mod pipe that combines its inputs by applying the
provided function to each sample. |
protected Mod |
modFn(Pipe pipe,
DoubleBinaryOperator function)
Create a
Mod pipe that combines its inputs by applying the
provided function to each sample. |
long |
nanos()
Query the time in nanoseconds, based on the sample playback clock.
|
protected double |
noteToFrequency(String note)
Convert the given note expressed as a String (eg.
|
protected int |
noteToMidi(String note)
Convert the given note expressed as a String (eg.
|
protected Pipe |
out(int index)
Access the Pipe for the specified output channel.
|
long |
position()
Query the position in samples.
|
protected void |
removeDependent(Graph.Dependent dependent)
Remove a
Graph.Dependent from the graph. |
double |
sampleRate()
Query the sample rate in Hz.
|
ScheduledExecutorService |
scheduler()
Get a
ScheduledExecutorService for running tasks on the audio
thread. |
protected double |
tabread(AudioTable table,
double position)
Read from the first channel of the given
AudioTable using a
normalized position (0 .. |
protected Tee |
tee()
Create a
Tee pipe that can split its input to multiple outputs. |
protected void |
update()
Optional update hook called before every buffer is processed.
|
protected Graph()
protected Graph(int inputCount,
int outputCount)
inputCount - number of input channels (can be zero)outputCount - number of output channelsprotected abstract void init()
protected void update()
public long position()
public int blockSize()
public double sampleRate()
public long millis()
public long nanos()
public void invokeLater(Runnable task)
task - task to runpublic ScheduledExecutorService scheduler()
ScheduledExecutorService for running tasks on the audio
thread. This method is safe to call from another thread. The scheduler
cannot be terminated and will throw an exception if attempting to
shutdown or await termination.protected void addDependent(Graph.Dependent dependent)
Graph.Dependent to the graph.dependent - dependent to addprotected void removeDependent(Graph.Dependent dependent)
Graph.Dependent from the graph.dependent - dependent to removeprotected final Pipe in(int index)
index - input channelprotected final Pipe out(int index)
index - output channelprotected final Pipe link(Pipe... ugens)
ugens - list of Pipes to connectprotected final Add add()
Add Pipe. This unit type can add together multiple
inputs.protected final Add add(Pipe... ugens)
Add Pipe, and add the provided Pipes as inputs to it.
This unit type can add together multiple inputs. Additional inputs may be
added later.ugens - list of Pipes to addprotected final Mod mod()
Mod pipe. The Mod pipe accepts multiple inputs and an
optional function to combine them. The default function is to multiply
samples together.protected final Mod mod(Pipe... ugens)
Mod pipe, and add the provided Pipes as inputs to it.
The Mod pipe accepts multiple inputs and an optional function to combine
them. The default function is to multiply samples together.protected final Mod modFn(DoubleBinaryOperator function)
Mod pipe that combines its inputs by applying the
provided function to each sample.function - operation to apply to each sampleprotected final Mod modFn(Pipe pipe, DoubleBinaryOperator function)
Mod pipe that combines its inputs by applying the
provided function to each sample. The provided Pipe will be added as the
first input.pipe - input pipefunction - operation to apply to each sampleprotected final Tee tee()
Tee pipe that can split its input to multiple outputs.
The input data is buffered, so the Tee may be connected to pipes that
feed into its input. This will create a delay of one block size.protected final Fn fn(DoubleUnaryOperator function)
Fn Pipe that applies the given operation to every
sample.function - operation to apply to each sampleprotected final double noteToFrequency(String note)
note - String representation of a noteprotected final int noteToMidi(String note)
note - String representation of a noteprotected final double midiToFrequency(int midi)
midi - note numberprotected double tabread(AudioTable table, double position)
AudioTable using a
normalized position (0 .. 1). Out of range values or a null table will
return silence. The returned sample is interpolated where required when
the position is between sample points.table - audio data to read fromposition - position normalized 0 .. 1Copyright © 2020. All rights reserved.