public class TrapezoidWave extends UGen
Generates a pulse-wave with adjustable duty cycle and "attack"/"decay" lengths. Duty cycle indicates the portion of the waveform that is greater than 0; "attack" and "decay" indicate the lengths of linear ramps between -1 and 1.
Several common waveforms can be generated using the following values (though
it should be noted that if all you want are these common waveforms, you might
prefer WavePlayer
).
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
Modifier and Type | Field and Description |
---|---|
protected float |
a |
protected float |
abSlope |
protected float |
attack |
protected UGen |
attackUGen |
protected float |
b |
protected float |
c |
protected float |
cdSlope |
protected float |
decay |
protected UGen |
decayUGen |
protected float |
delta |
protected float |
dutyCycle |
protected UGen |
dutyCycleUGen |
protected float |
freq |
protected UGen |
freqUGen |
protected float |
index |
protected float |
iSampleRate |
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
Constructor and Description |
---|
TrapezoidWave(AudioContext con)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateBuffer()
Called by the signal chain to update this UGen's ouput data.
|
protected void |
calcVals() |
float |
getAttack()
Gets the current attack length.
|
UGen |
getAttackUGen()
Gets the attack length controller UGen, if there is one.
|
float |
getDecay()
Gets the current decay length.
|
UGen |
getDecayUGen()
Gets the UGen controlling the decay length, if there is one.
|
float |
getDutyCycle()
Gets the current duty cycle.
|
UGen |
getDutyCycleUGen()
Gets the UGen controlling the duty cycle, if there is one.
|
float |
getFrequency()
Gets the current frequency.
|
UGen |
getFrequencyUGen()
Gets the UGen controlling the frequency, if there is one.
|
TrapezoidWave |
setAttack(float attack)
Sets the attack length to a float value.
|
TrapezoidWave |
setAttack(UGen attackUGen)
Sets a UGen to control the attack length.
|
TrapezoidWave |
setDecay(float decay)
Sets the decay length to a float value.
|
TrapezoidWave |
setDecay(UGen decayUGen)
Sets a UGen to control the decay length.
|
TrapezoidWave |
setDutyCycle(float dutyCycle)
Sets the duty cycle to a float value.
|
TrapezoidWave |
setDutyCycle(UGen dutyCycleUGen)
Sets a UGen to control the duty cycle.
|
TrapezoidWave |
setFrequency(float freq)
Sets the frequency to a float value.
|
TrapezoidWave |
setFrequency(UGen freqUGen)
Sets a UGen to control the frequency.
|
addDependent, addInput, addInput, clearDependents, clearInputConnections, containsInput, crossfadeInput, getConnectedInputs, getContext, getEnvelopes, getIns, getNumberOfConnectedUGens, getNumberOfDependents, getOutBuffer, getOuts, getTimeTakenLastUpdate, getValue, getValue, getValueDouble, getValueDouble, initializeOuts, isTimerMode, isUpdated, noInputs, pause, printInBuffers, printInputList, printOutBuffers, removeAllConnections, removeConnection, removeDependent, setOutsToPause, setTimerMode, setValue, update, zeroIns, zeroOuts
getKillListener, getName, isDeleted, isPaused, kill, message, messageReceived, setKillListener, setName, start, toString
protected float index
protected float a
protected float b
protected float c
protected float abSlope
protected float cdSlope
protected float freq
protected float dutyCycle
protected float attack
protected float decay
protected float delta
protected float iSampleRate
protected UGen freqUGen
protected UGen dutyCycleUGen
protected UGen attackUGen
protected UGen decayUGen
public TrapezoidWave(AudioContext con)
con
- The AudioContext.public void calculateBuffer()
UGen
UGen.bufIn
and putting data
into UGen.bufOut
in some way. UGen.bufIn
and UGen.bufOut
are 2D arrays of floats of the form float[numChannels][bufferSize]. The length of the buffers is given by
UGen.bufferSize
, and the number of channels of the input and output buffers are given by UGen.ins
and UGen.outs
respectively.calculateBuffer
in class UGen
protected void calcVals()
public TrapezoidWave setFrequency(float freq)
freq
- The frequency.public TrapezoidWave setFrequency(UGen freqUGen)
freqUGen
- The frequency controller UGen.public float getFrequency()
public UGen getFrequencyUGen()
public TrapezoidWave setDutyCycle(UGen dutyCycleUGen)
dutyCycleUGen
- The duty cycle controller UGen.public TrapezoidWave setDutyCycle(float dutyCycle)
dutyCycle
- The duty cycle.public float getDutyCycle()
public UGen getDutyCycleUGen()
public TrapezoidWave setAttack(UGen attackUGen)
attackUGen
- The attack length controller UGen.public TrapezoidWave setAttack(float attack)
attack
- The attack length.public float getAttack()
public UGen getAttackUGen()
public TrapezoidWave setDecay(UGen decayUGen)
decayUGen
- The decay length controller UGen.public TrapezoidWave setDecay(float decay)
decay
- The decay length value.public float getDecay()
public UGen getDecayUGen()