public class SynthesisEngine extends java.lang.Object implements Synthesizer
Synthesizer
Modifier and Type | Field and Description |
---|---|
static double |
DB90
A fraction that is approximately -90.3 dB.
|
static double |
DB96
A fraction corresponding to exactly -96 dB.
|
static int |
DEFAULT_FRAME_RATE |
FRAMES_PER_BLOCK
Constructor and Description |
---|
SynthesisEngine() |
SynthesisEngine(AudioDeviceManager audioDeviceManager) |
Modifier and Type | Method and Description |
---|---|
void |
add(UnitGenerator ugen)
Add a unit generator to the synthesizer so it can be played.
|
void |
addAudioTask(java.lang.Runnable blockTask)
Add a task that will get run on the Audio Thread before it generates a new block of Audio.
|
void |
autoStopUnit(UnitGenerator unitGenerator) |
void |
clearCommandQueue()
Clear all scheduled commands from the queue.
|
static short |
convertDoubleToShort(double d)
Convert a double value in the range -1.0 to almost 1.0 to a short.
|
static double |
convertShortToDouble(short sdata)
Convert a short value to a double in the range -1.0 to almost 1.0.
|
double |
convertTimeToExponentialScaler(double duration) |
TimeStamp |
createTimeStamp()
Create a TimeStamp using the current audio time.
|
void |
generateNextBuffer() |
AudioDeviceManager |
getAudioDeviceManager()
An AudioDeviceManager is an interface to audio hardware.
|
double |
getCurrentTime() |
long |
getFrameCount()
This count is not reset if you stop and restart.
|
double |
getFramePeriod() |
int |
getFrameRate() |
double[] |
getInputBuffer(int i) |
double |
getInputLatency() |
double |
getInverseNyquist() |
double[] |
getOutputBuffer(int i) |
double |
getOutputLatency() |
double |
getUsage() |
java.lang.String |
getVersion() |
int |
getVersionCode() |
boolean |
isPullDataEnabled() |
boolean |
isRealTime()
Is JSyn running in real-time mode?
|
boolean |
isRunning() |
void |
printConnections() |
void |
queueCommand(ScheduledCommand command)
Queue a command to be processed as soon as possible in the background audio thread.
|
void |
remove(UnitGenerator ugen)
Removes a unit generator added using add().
|
void |
removeAudioTask(java.lang.Runnable blockTask) |
void |
scheduleCommand(double time,
ScheduledCommand command)
Queue a command to be processed at a specific time in the background audio thread.
|
void |
scheduleCommand(TimeStamp timeStamp,
ScheduledCommand command)
Queue a command to be processed at a specific time in the background audio thread.
|
void |
setPullDataEnabled(boolean pullDataEnabled)
If set true then audio data will be pulled from the output ports of connected unit
generators.
|
void |
setRealTime(boolean realTime)
If set true then the synthesizer will generate audio in real-time.
|
void |
sleepFor(double duration)
Sleep for the specified audio time duration.
|
void |
sleepUntil(double time)
Sleep until the specified audio time is reached.
|
void |
start()
Starts a background thread that generates audio using the default frame rate of 44100 and two
stereo output channels.
|
void |
start(int frameRate)
Starts a background thread that generates audio using the specified frame rate and two stereo
output channels.
|
void |
start(int frameRate,
int inputDeviceID,
int numInputChannels,
int outputDeviceID,
int numOutputChannels)
Starts the synthesizer using specific audio devices.
|
void |
startUnit(UnitGenerator unit)
The startUnit and stopUnit methods are mainly for internal use.
|
void |
startUnit(UnitGenerator unit,
double time)
Start a unit generator at the specified time.
|
void |
startUnit(UnitGenerator unit,
TimeStamp timeStamp) |
void |
stop()
Stops the background thread that generates the audio.
|
void |
stopUnit(UnitGenerator unit)
The startUnit and stopUnit methods are mainly for internal use.
|
void |
stopUnit(UnitGenerator unit,
double time) |
void |
stopUnit(UnitGenerator unit,
TimeStamp timeStamp) |
void |
terminate() |
java.lang.String |
toString() |
public static final int DEFAULT_FRAME_RATE
public static final double DB96
public static final double DB90
public SynthesisEngine(AudioDeviceManager audioDeviceManager)
public SynthesisEngine()
public java.lang.String getVersion()
getVersion
in interface Synthesizer
public int getVersionCode()
getVersionCode
in interface Synthesizer
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isPullDataEnabled()
public void setPullDataEnabled(boolean pullDataEnabled)
pullDataEnabled
- public void terminate()
public void start()
Synthesizer
start
in interface Synthesizer
public void start(int frameRate)
Synthesizer
start
in interface Synthesizer
frameRate
- in Hertzpublic void start(int frameRate, int inputDeviceID, int numInputChannels, int outputDeviceID, int numOutputChannels)
Synthesizer
start
in interface Synthesizer
frameRate
- in HertzinputDeviceID
- obtained from an AudioDeviceManager
or pass
AudioDeviceManager.USE_DEFAULT_DEVICEnumInputChannels
- 1 for mono, 2 for stereo, etceteraoutputDeviceID
- obtained from an AudioDeviceManager or pass
AudioDeviceManager.USE_DEFAULT_DEVICEnumOutputChannels
- 1 for mono, 2 for stereo, etceterapublic boolean isRunning()
isRunning
in interface Synthesizer
public void stop()
Synthesizer
stop
in interface Synthesizer
public void generateNextBuffer()
public double getCurrentTime()
getCurrentTime
in interface Synthesizer
public TimeStamp createTimeStamp()
Synthesizer
createTimeStamp
in interface Synthesizer
public void scheduleCommand(TimeStamp timeStamp, ScheduledCommand command)
Synthesizer
scheduleCommand
in interface Synthesizer
public void scheduleCommand(double time, ScheduledCommand command)
Synthesizer
scheduleCommand
in interface Synthesizer
public void queueCommand(ScheduledCommand command)
Synthesizer
queueCommand
in interface Synthesizer
public void clearCommandQueue()
Synthesizer
clearCommandQueue
in interface Synthesizer
public double[] getInputBuffer(int i)
public double[] getOutputBuffer(int i)
public void autoStopUnit(UnitGenerator unitGenerator)
public void startUnit(UnitGenerator unit, double time)
Synthesizer
startUnit
in interface Synthesizer
public void stopUnit(UnitGenerator unit, double time)
stopUnit
in interface Synthesizer
public void startUnit(UnitGenerator unit, TimeStamp timeStamp)
startUnit
in interface Synthesizer
public void stopUnit(UnitGenerator unit, TimeStamp timeStamp)
stopUnit
in interface Synthesizer
public void startUnit(UnitGenerator unit)
Synthesizer
startUnit
in interface Synthesizer
public void stopUnit(UnitGenerator unit)
Synthesizer
stopUnit
in interface Synthesizer
public double getInverseNyquist()
public double convertTimeToExponentialScaler(double duration)
public long getFrameCount()
Synthesizer
getFrameCount
in interface Synthesizer
public int getFrameRate()
getFrameRate
in interface Synthesizer
public double getFramePeriod()
getFramePeriod
in interface Synthesizer
public static double convertShortToDouble(short sdata)
public static short convertDoubleToShort(double d)
public void addAudioTask(java.lang.Runnable blockTask)
Synthesizer
addAudioTask
in interface Synthesizer
public void removeAudioTask(java.lang.Runnable blockTask)
removeAudioTask
in interface Synthesizer
public double getUsage()
getUsage
in interface Synthesizer
public AudioDeviceManager getAudioDeviceManager()
Synthesizer
getAudioDeviceManager
in interface Synthesizer
public void setRealTime(boolean realTime)
Synthesizer
setRealTime
in interface Synthesizer
public boolean isRealTime()
Synthesizer
isRealTime
in interface Synthesizer
public double getOutputLatency()
public double getInputLatency()
public void add(UnitGenerator ugen)
Synthesizer
add
in interface Synthesizer
ugen
- a unit generator to be executed by the synthesizerpublic void remove(UnitGenerator ugen)
Synthesizer
remove
in interface Synthesizer
public void sleepUntil(double time) throws java.lang.InterruptedException
Synthesizer
sleepUntil
in interface Synthesizer
java.lang.InterruptedException
public void sleepFor(double duration) throws java.lang.InterruptedException
Synthesizer
sleepFor
in interface Synthesizer
java.lang.InterruptedException
public void printConnections()