net.beadsproject.beads.ugens
Class TrapezoidWave

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.core.UGen
          extended by net.beadsproject.beads.ugens.TrapezoidWave

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).

Version:
0.9.5
Author:
Benito Crawford

Nested Class Summary
 
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
 
Field Summary
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
           
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
TrapezoidWave(AudioContext con)
          Constructor.
 
Method Summary
 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.
 
Methods inherited from class net.beadsproject.beads.core.UGen
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
 
Methods inherited from class net.beadsproject.beads.core.Bead
getKillListener, getName, isDeleted, isPaused, kill, message, messageReceived, setKillListener, setName, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected float index

a

protected float a

b

protected float b

c

protected float c

abSlope

protected float abSlope

cdSlope

protected float cdSlope

freq

protected float freq

dutyCycle

protected float dutyCycle

attack

protected float attack

decay

protected float decay

delta

protected float delta

iSampleRate

protected float iSampleRate

freqUGen

protected UGen freqUGen

dutyCycleUGen

protected UGen dutyCycleUGen

attackUGen

protected UGen attackUGen

decayUGen

protected UGen decayUGen
Constructor Detail

TrapezoidWave

public TrapezoidWave(AudioContext con)
Constructor.

Parameters:
con - The AudioContext.
Method Detail

calculateBuffer

public void calculateBuffer()
Description copied from class: UGen
Called by the signal chain to update this UGen's ouput data. Subclassses of UGen should implement the UGen's DSP perform routine here. In general this involves grabbing data from 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.

Specified by:
calculateBuffer in class UGen

calcVals

protected void calcVals()

setFrequency

public TrapezoidWave setFrequency(float freq)
Sets the frequency to a float value.

Parameters:
freq - The frequency.
Returns:
This TrapezoidWave instance.

setFrequency

public TrapezoidWave setFrequency(UGen freqUGen)
Sets a UGen to control the frequency.

Parameters:
freqUGen - The frequency controller UGen.
Returns:
This TrapezoidWave instance.

getFrequency

public float getFrequency()
Gets the current frequency.

Returns:
The frequency.

getFrequencyUGen

public UGen getFrequencyUGen()
Gets the UGen controlling the frequency, if there is one.

Returns:
The frequency UGen.

setDutyCycle

public TrapezoidWave setDutyCycle(UGen dutyCycleUGen)
Sets a UGen to control the duty cycle.

Parameters:
dutyCycleUGen - The duty cycle controller UGen.
Returns:
This TrapezoidWave instance.

setDutyCycle

public TrapezoidWave setDutyCycle(float dutyCycle)
Sets the duty cycle to a float value.

Parameters:
dutyCycle - The duty cycle.
Returns:
This TrapezoidWave instance.

getDutyCycle

public float getDutyCycle()
Gets the current duty cycle.

Returns:
The duty cycle.

getDutyCycleUGen

public UGen getDutyCycleUGen()
Gets the UGen controlling the duty cycle, if there is one.

Returns:
The duty cycle controller UGen.

setAttack

public TrapezoidWave setAttack(UGen attackUGen)
Sets a UGen to control the attack length.

Parameters:
attackUGen - The attack length controller UGen.
Returns:
This TrapezoidWave instance.

setAttack

public TrapezoidWave setAttack(float attack)
Sets the attack length to a float value.

Parameters:
attack - The attack length.
Returns:
This TrapezoidWave instance.

getAttack

public float getAttack()
Gets the current attack length.

Returns:
The attack length.

getAttackUGen

public UGen getAttackUGen()
Gets the attack length controller UGen, if there is one.

Returns:
The attack length controller UGen.

setDecay

public TrapezoidWave setDecay(UGen decayUGen)
Sets a UGen to control the decay length.

Parameters:
decayUGen - The decay length controller UGen.
Returns:
This TrapezoidWave instance.

setDecay

public TrapezoidWave setDecay(float decay)
Sets the decay length to a float value.

Parameters:
decay - The decay length value.
Returns:
This TrapezoidWave instance.

getDecay

public float getDecay()
Gets the current decay length.

Returns:
The decay length.

getDecayUGen

public UGen getDecayUGen()
Gets the UGen controlling the decay length, if there is one.

Returns:
The decay controller UGen.