public class AudioOutput extends AudioSource implements Polyphonic
An AudioOutput is a connection to the output of a computer's sound card. Typically the computer speakers are connected to this. You can use an AudioOutput to do real-time sound synthesis by patching UGens to an output object. You can get an AudioOutput object from Minim using one of five methods:
AudioOutput getLineOut() // specifiy either Minim.MONO or Minim.STEREO for type AudioOutput getLineOut(int type) // bufferSize is the size of the left, right, // and mix buffers of the output you get back AudioOutput getLineOut(int type, int bufferSize) // sampleRate is a request for an output of a certain sample rate AudioOutput getLineOut(int type, int bufferSize, float sampleRate) // bitDepth is a request for an output with a certain bit depth AudioInput getLineOut(int type, int bufferSize, float sampleRate, int bitDepth)
In the event that an output doesn't exist with the requested parameters, Minim will spit out an error and return null. In general, you will want to use one of the first two methods listed above.
In addition to directly patching UGens to the output, you can also schedule "notes" to be played by the output at some time in the future. This can be very powerful when writing algorithmic music and sound. See the playNote method for more information.
left, mix, right
BALANCE, GAIN, MUTE, PAN, SAMPLE_RATE, VOLUME
Constructor and Description |
---|
AudioOutput(ddf.minim.spi.AudioOut out)
Constructs an
AudioOutput that will use out
to generate sound. |
Modifier and Type | Method and Description |
---|---|
void |
addSignal(AudioSignal signal)
Deprecated.
|
void |
clearSignals()
Deprecated.
|
void |
disableSignal(AudioSignal signal)
Deprecated.
|
void |
disableSignal(int i)
Deprecated.
|
void |
enableSignal(AudioSignal signal)
Deprecated.
|
void |
enableSignal(int i)
Deprecated.
|
float |
getDurationFactor()
Return the current value of the duration factor for this output.
|
float |
getNoteOffset()
Return the current value of the note offset for this output.
|
AudioSignal |
getSignal(int i)
Deprecated.
|
float |
getTempo()
Return the current tempo of the AudioOuput.
|
boolean |
hasSignal(AudioSignal signal)
Deprecated.
|
boolean |
isEnabled(AudioSignal signal)
Deprecated.
|
boolean |
isSounding()
Deprecated.
|
void |
noSound()
Deprecated.
|
void |
pauseNotes()
An AudioOutput processes its note queue in its own Thread,
so if you are going to queue up a lot of notes at once
you will want to use the
pauseNotes method before queuing
them. |
void |
playNote()
Schedule a "note" to played by the output that uses the default Instrument,
has a duration of 1 beat, is played immediately, and has a pitch of "A4".
|
void |
playNote(float hz)
Schedule a "note" to played by the output that uses the default Instrument, has a duration of 1 beat,
and is played immediately.
|
void |
playNote(float startTime,
float hz)
Schedule a "note" to played by the output that uses the default Instrument and has a duration of 1 beat.
|
void |
playNote(float startTime,
float duration,
float hz)
Schedule a "note" to played by the output that uses the default Instrument.
|
void |
playNote(float startTime,
float duration,
Instrument instrument)
playNote is a method of scheduling a "note" to be played at
some time in the future (or immediately), where a "note" is
an instance of a class that implements the Instrument interface.
|
void |
playNote(float startTime,
float duration,
java.lang.String pitchName)
Schedule a "note" to played by the output that uses the default Instrument.
|
void |
playNote(float startTime,
java.lang.String pitchName)
Schedule a "note" to played by the output that uses the default Instrument and has a duration of 1 beat.
|
void |
playNote(java.lang.String pitchName)
Schedule a "note" to played by the output that uses the default Instrument,
has a duration of 1 beat, and is played immediately.
|
void |
removeSignal(AudioSignal signal)
Deprecated.
|
AudioSignal |
removeSignal(int i)
Deprecated.
|
void |
resumeNotes()
Resume note processing.
|
void |
setDurationFactor(float durationFactor)
The duration factor of an AudioOutput defines how durations passed to playNote calls
are scaled before being queued.
|
void |
setNoteOffset(float noteOffset)
When writing out musical scores in code, it is often nice to think about
music in sections, where all of the playNote calls have start times relative to
the beginning of the section.
|
void |
setTempo(float tempo)
The tempo of an AudioOutput controls how it will interpret the start time and duration
arguments of playNote methods.
|
int |
signalCount()
Deprecated.
|
void |
sound()
Deprecated.
|
addEffect, addListener, bufferSize, clearEffects, close, disableEffect, disableEffect, effectCount, effects, enableEffect, enableEffect, getEffect, getFormat, hasEffect, isEffected, isEnabled, noEffects, removeEffect, removeEffect, removeListener, sampleRate, type
balance, gain, getBalance, getControl, getControls, getGain, getPan, getVolume, hasControl, isMuted, mute, pan, printControls, setBalance, setGain, setPan, setVolume, shiftBalance, shiftGain, shiftPan, shiftVolume, unmute, volume
public AudioOutput(ddf.minim.spi.AudioOut out)
AudioOutput
that will use out
to generate sound.out
- the AudioOut
that does most of our workpublic void addSignal(AudioSignal signal)
Polyphonic
addSignal
in interface Polyphonic
signal
- the AudioSignal
to addpublic AudioSignal getSignal(int i)
Polyphonic
ith
signal in the signal chain.
This method is not required to do bounds checking and may throw an
ArrayOutOfBoundsException if i
is larger than
Polyphonic.signalCount()
.getSignal
in interface Polyphonic
i
- which signal to returnpublic void removeSignal(AudioSignal signal)
Polyphonic
signal
from the signals chain.removeSignal
in interface Polyphonic
signal
- the AudioSignal to removepublic AudioSignal removeSignal(int i)
Polyphonic
ith
signal in the
signal chain.removeSignal
in interface Polyphonic
i
- which signal to removeAudioSignal
public void clearSignals()
Polyphonic
clearSignals
in interface Polyphonic
public void disableSignal(int i)
Polyphonic
i
th signal in the signal chain.disableSignal
in interface Polyphonic
i
- the index of the signal to disablepublic void disableSignal(AudioSignal signal)
Polyphonic
signal
if it is in the chain.disableSignal
in interface Polyphonic
signal
- the AudioSignal
to disablepublic void enableSignal(int i)
Polyphonic
i
th signal in the signal chain.enableSignal
in interface Polyphonic
i
- the index of the signal to enablepublic void enableSignal(AudioSignal signal)
Polyphonic
signal
if it is in the chain.enableSignal
in interface Polyphonic
signal
- the AudioSignal
to enablepublic boolean isEnabled(AudioSignal signal)
Polyphonic
signal
is in the chain and is also enabled.isEnabled
in interface Polyphonic
signal
- the AudioSignal
to check the status ofsignal
is in the chain and is enabledpublic boolean isSounding()
Polyphonic
isSounding
in interface Polyphonic
public void noSound()
Polyphonic
Polyphonic.disableSignal(int)
.noSound
in interface Polyphonic
public int signalCount()
Polyphonic
signalCount
in interface Polyphonic
public void sound()
Polyphonic
Polyphonic.enableSignal(int)
.sound
in interface Polyphonic
public boolean hasSignal(AudioSignal signal)
hasSignal
in interface Polyphonic
public void playNote(float startTime, float duration, Instrument instrument)
Versions of playNote that do not have an Instrument argument will create an instance of a default Instrument that plays a sine tone based on the parameters passed in.
To facilitate writing algorithmic music, the start time and duration of a note is expressed in beats and not in seconds. By default, the tempo of an AudioOutput will be 60 BPM (beats per minute), which means that beats are equivalent to seconds. If you want to think in seconds when writing your note playing code, then simply don't change the tempo of the output.
Another thing to keep in mind is that the AudioOutput processes its note queue in its own Thread, so if you are going to queue up a lot of notes at once you will want to use the pauseNotes method before queuing them. If you don't, the timing will be slightly off because the "now" that the start time of each note is an offset from will change from note to note. Once all of your notes have been added, you call resumeNotes to allow the AudioOutput to process notes again.
startTime
- float: when the note should begin playing, in beatsduration
- float: how long the note should be, in beatsinstrument
- the Instrument that will play the notepublic void playNote(float startTime, float duration, float hz)
startTime
- float: when the note should begin playing, in beatsduration
- float: how long the note should be, in beatshz
- float: the frequency, in Hertz, of the note to be playedplayNote(float, float, Instrument)
public void playNote(float startTime, float duration, java.lang.String pitchName)
startTime
- float: when the note should begin playing, in beatsduration
- float: how long the note should be, in beatspitchName
- String: the pitch name of the note to be played (e.g. "A4" or "Bb3")playNote(float, float, Instrument)
public void playNote(float startTime, float hz)
startTime
- float: when the note should begin playing, in beatshz
- float: the frequency, in Hertz, of the note to be playedplayNote(float, float, Instrument)
public void playNote(float startTime, java.lang.String pitchName)
startTime
- float: when the note should begin playing, in beatspitchName
- String: the pitch name of the note to be played (e.g. "A4" or "Bb3")playNote(float, float, Instrument)
public void playNote(float hz)
hz
- float: the frequency, in Hertz, of the note to be playedplayNote(float, float, Instrument)
public void playNote(java.lang.String pitchName)
pitchName
- String: the pitch name of the note to be played (e.g. "A4" or "Bb3")playNote(float, float, Instrument)
public void playNote()
playNote(float, float, Instrument)
public void setTempo(float tempo)
tempo
- float: the new tempo for the AudioOutput, in BPM (beats per minute)public float getTempo()
public void setNoteOffset(float noteOffset)
By default, note offset is 0.
noteOffset
- float: the amount of time added to all start times passed to playNote calls.public float getNoteOffset()
public void setDurationFactor(float durationFactor)
By default the duration factor is 1.
durationFactor
- float: the duration factorpublic float getDurationFactor()
public void pauseNotes()
pauseNotes
method before queuing
them. If you don't, the timing will be slightly off because the "now" that
the start time of each note is an offset from will change from note to note.
Once all of your notes have been added, you call resumeNotes
to allow
the AudioOutput to process notes again.public void resumeNotes()
pauseNotes()