|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ddf.minim.signals.Oscillator
public abstract class Oscillator
Oscillator
is an implementation of an AudioSignal
that handles most of the work associated with an oscillatory signal like a
sine wave. To create your own oscillator you must extend
Oscillator
and implement the value
method. Oscillator
will call this method every time it needs
to sample your waveform. The number passed to the method is an offset from
the beginning of the waveform's period and should be used to sample your
waveform at that point.
Field Summary | |
---|---|
protected static float |
TWO_PI
The float value of 2*PI. |
Constructor Summary | |
---|---|
Oscillator(float frequency,
float amplitude,
float sampleRate)
Constructs an Oscillator with the requested frequency, amplitude and sample rate. |
Method Summary | |
---|---|
float |
amplitude()
Returns the current amplitude. |
float |
frequency()
Returns the current frequency. |
void |
generate(float[] signal)
Fills signal with values in the range of [-1, 1]. |
void |
generate(float[] left,
float[] right)
Fills left and right with values in the range
of [-1, 1]. |
void |
noPortamento()
Turns off portamento. |
float |
pan()
Returns the current pan value. |
float |
period()
Returns the period of the waveform (the inverse of the frequency). |
void |
portamento(int millis)
Sets how many milliseconds it should take to transition from one frequency to another when setting a new frequency. |
float |
sampleRate()
|
void |
setAmp(float a)
Set the amplitude of the Oscillator, range is [0, 1]. |
void |
setAudioListener(AudioListener al)
|
void |
setFreq(float f)
Sets the frequency of the Oscillator in Hz. |
void |
setPan(float p)
Set the pan of the Oscillator, range is [-1, 1]. |
void |
setPanNoGlide(float p)
Set the pan of the Oscillator, but don't smoothly transition from whatever the current pan value is to this new one. |
protected abstract float |
value(float step)
Returns the value of the waveform at step . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final float TWO_PI
Constructor Detail |
---|
public Oscillator(float frequency, float amplitude, float sampleRate)
frequency
- the frequency of the Oscillatoramplitude
- the amplitude of the OscillatorsampleRate
- the sample rate of the OscillatorMethod Detail |
---|
public final float sampleRate()
public final void setFreq(float f)
f
.
f
- the new frequency of the Oscillatorpublic final float frequency()
public final void setAmp(float a)
a
- the new amplitude, it will be constrained to [0, 1]public final float amplitude()
public final void setPan(float p)
p
- -
the new pan value, it will be constrained to [-1, 1]public final void setPanNoGlide(float p)
p
- -
the new pan value, it will be constrained to [-1,1]public final float pan()
public final void portamento(int millis)
millis
- the length of the portamentopublic final void noPortamento()
public final void generate(float[] signal)
AudioSignal
signal
with values in the range of [-1, 1].
signal
represents a mono audio signal.
generate
in interface AudioSignal
signal
- the float array to fillpublic final void generate(float[] left, float[] right)
AudioSignal
left
and right
with values in the range
of [-1, 1]. left
represents the left channel of a stereo
signal, right
represents the right channel of that same
stereo signal.
generate
in interface AudioSignal
left
- the left channelright
- the right channelpublic final void setAudioListener(AudioListener al)
public final float period()
protected abstract float value(float step)
step
. To take
advantage of all of the work that Oscillator
does, you can
create your own periodic waveforms by extending Oscillator
and implementing this function. All of the oscillators included with Minim
were created in this way.
step
- an offset from the beginning of the waveform's period
step
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |