ddf.minim.signals
Class PulseWave

java.lang.Object
  extended by ddf.minim.signals.Oscillator
      extended by ddf.minim.signals.PulseWave
All Implemented Interfaces:
AudioSignal

public class PulseWave
extends Oscillator

A pulse wave is a square wave whose peaks and valleys are different length. The pulse width of a pulse wave is how wide the peaks.

Author:
Damien Di Fede
See Also:
Pulse Wave

Field Summary
 
Fields inherited from class ddf.minim.signals.Oscillator
TWO_PI
 
Constructor Summary
PulseWave(float frequency, float amplitude, float sampleRate)
          Constructs a pulse wave with the given frequency, amplitude and sample rate.
 
Method Summary
 float getPulseWidth()
          Returns the current pulse width.
 void setPulseWidth(float w)
          Sets the pulse width of the pulse wave.
protected  float value(float step)
          Returns the value of the waveform at step.
 
Methods inherited from class ddf.minim.signals.Oscillator
amplitude, frequency, generate, generate, noPortamento, pan, period, portamento, sampleRate, setAmp, setAudioListener, setFreq, setPan, setPanNoGlide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PulseWave

public PulseWave(float frequency,
                 float amplitude,
                 float sampleRate)
Constructs a pulse wave with the given frequency, amplitude and sample rate.

Parameters:
frequency - the frequency of the pulse wave
amplitude - the amplitude of the pulse wave
sampleRate - the sample rate of the pulse wave
Method Detail

setPulseWidth

public void setPulseWidth(float w)
Sets the pulse width of the pulse wave.

Parameters:
w - the new pulse width, this will be constrained to [1, 30]

getPulseWidth

public float getPulseWidth()
Returns the current pulse width.

Returns:
the current pulse width

value

protected float value(float step)
Description copied from class: Oscillator
Returns the value of the waveform at 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.

Specified by:
value in class Oscillator
Parameters:
step - an offset from the beginning of the waveform's period
Returns:
the value of the waveform at step