public class Synthesizer extends AudioStream implements Instrument
Modifier and Type | Class and Description |
---|---|
static class |
Synthesizer.FMOptions
Options class for FM synthesis.
|
static interface |
Synthesizer.OscillatorOptions
Interface for options.
|
Constructor and Description |
---|
Synthesizer() |
Modifier and Type | Method and Description |
---|---|
void |
addSynthesizerListener(SynthesizerListener sl)
Add a synth listener to this synth.
|
void |
applyADSREnvelope(SampleBuffer sb)
Applies the ADSR gain envelope to the samples generated by the
generator.
|
protected void |
fireSynthQuiet()
Fired when the synth finished the release phase.
|
long |
getAttack()
Get the ADSR attack time in milliseconds
|
long |
getDecay()
Get the ADSR decay time in milliseconds
|
char |
getEnvelopePhase()
Returns the phase of the ADSR envelope
|
long |
getLength()
Returns the length of the audio stream in milliseconds.
|
Oscillator |
getOscillator()
Returns the oscillator in use.
|
long |
getRelease()
Get the release time in milliseconds
|
float |
getSustain()
Get the ADSR sustain gain
|
boolean |
isNoteOn()
Returns whether the synth is playing a note or not.
|
SampleChunk |
nextSampleChunk()
Retrieve the next SampleChunk from the audio stream.
|
void |
noteOff()
Note off
|
void |
noteOff(int noteNumber)
Turn off the given note.
|
void |
noteOn()
Note on.
|
void |
noteOn(int noteNumber,
double velocity)
Play a note on the instrument.
|
void |
removeSynthesizerListener(SynthesizerListener sl)
remove the synth listener from this synth.
|
void |
reset()
Reset the audio stream.
|
void |
setAttack(long attack)
Set the ADSR attack time in milliseconds
|
void |
setDecay(long decay)
Set the ADSR decay time in milliseconds
|
void |
setFrequency(double f)
Set the frequency at which the synth will generate tones.
|
void |
setGain(int gain)
Set the gain at which the synth will generate tones
|
void |
setOscillatorType(Oscillator t)
Set the type of oscillator used to generate tones.
|
void |
setRelease(long release)
Set the ADSR release time in milliseconds
|
void |
setSustain(float sustain)
Set the ADSR sustain gain
|
iterator, seek
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public Synthesizer()
public SampleChunk nextSampleChunk()
nextSampleChunk
in class AudioStream
AudioStream.nextSampleChunk()
public void setFrequency(double f)
f
- The frequencypublic void setGain(int gain)
gain
- The gainpublic void setOscillatorType(Oscillator t)
t
- The type of oscillator.public Oscillator getOscillator()
public void reset()
reset
in class AudioStream
AudioStream.reset()
public long getLength()
getLength
in class AudioStream
AudioStream.getLength()
public void noteOn()
public void noteOff()
public boolean isNoteOn()
public void applyADSREnvelope(SampleBuffer sb)
sb
- The sample buffer to affectpublic char getEnvelopePhase()
public long getAttack()
public void setAttack(long attack)
attack
- the attack time in millisecondspublic long getDecay()
public void setDecay(long decay)
decay
- the decay time in millisecondspublic float getSustain()
public void setSustain(float sustain)
sustain
- the sustain gainpublic long getRelease()
public void setRelease(long release)
release
- the release time in millisecondspublic void addSynthesizerListener(SynthesizerListener sl)
sl
- The synth listenerpublic void removeSynthesizerListener(SynthesizerListener sl)
sl
- The synth listener to removeprotected void fireSynthQuiet()
public void noteOn(int noteNumber, double velocity)
noteOn
in interface Instrument
noteNumber
- The MIDI note numbervelocity
- The velocity (0-1)Instrument.noteOn(int, double)
public void noteOff(int noteNumber)
noteOff
in interface Instrument
noteNumber
- The note to turn off.Instrument.noteOff(int)