public class RandomPWM extends UGen implements DataBeadReceiver
setLengthExponent
).
A RandomPWM instance has three modes:
ALTERNATING
(default) - pulses alternate between -1 and 1.PULSING
(default) - pulses alternate between 0 and 1.NOISE
- pulses are distributed continuously between -1 and 1.SAW
- for random-length ramps between -1 and 1.RAMPED_NOISE
- for random-length ramps between random values between -1 and 1.NOISE_ENVELOPE
- for random-length ramps between random values between 0 and 1.Modifier and Type | Class and Description |
---|---|
static class |
RandomPWM.Mode |
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
Modifier and Type | Field and Description |
---|---|
static RandomPWM.Mode |
ALTERNATING |
protected float |
baseVal |
protected float |
count |
protected float |
lengthDiff |
protected float |
lengthExponent |
protected float |
maxLength |
protected float |
minLength |
protected RandomPWM.Mode |
mode |
static RandomPWM.Mode |
NOISE |
static RandomPWM.Mode |
NOISE_ENVELOPE |
protected float |
pulseLen |
static RandomPWM.Mode |
PULSING |
static RandomPWM.Mode |
RAMPED_NOISE |
static RandomPWM.Mode |
SAW |
protected float |
targetVal |
protected float |
valDiff |
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
Constructor and Description |
---|
RandomPWM(AudioContext context,
RandomPWM.Mode mode,
float minl,
float maxl)
Constructor specifying mode, and minumum and maximum pulse lengths.
|
RandomPWM(AudioContext context,
RandomPWM.Mode mode,
float minl,
float maxl,
float lexp)
Constructor specifying all parameters
|
Modifier and Type | Method and Description |
---|---|
void |
calculateBuffer()
Called by the signal chain to update this UGen's ouput data.
|
protected void |
calcVals() |
float |
getLengthExponent()
Gets the pulse length exponent.
|
float |
getMaxLength()
Gets the maximum pulse length.
|
float |
getMinLength()
Gets the minimum pulse length.
|
RandomPWM.Mode |
getMode()
Gets the pulse mode.
|
DataBead |
getParams()
Gets a DataBead filled with properties corresponding to this object's
parameters.
|
void |
messageReceived(Bead message)
Responds to an incoming message.
|
DataBeadReceiver |
sendData(DataBead db)
Use the properties "mode", "minLength", "maxLength", and "lengthExponent"
to set the corresponding parameters (type Mode for "mode", floats only for the others).
|
RandomPWM |
setLengthExponent(float lexp)
Sets the pulse length exponent.
|
RandomPWM |
setMaxLength(float maxl)
Sets the maximum pulse length.
|
RandomPWM |
setMinLength(float minl)
Sets the minimum pulse length.
|
RandomPWM |
setMode(RandomPWM.Mode mode)
Sets the pulse mode.
|
RandomPWM |
setParams(float minl,
float maxl,
float lexp)
Sets the minimum pulse length, maximum pulse length, and pulse length
exponent.
|
RandomPWM |
setParams(RandomPWM.Mode mode,
float minl,
float maxl,
float lexp)
Sets the pulse mode (see
setMode ), minimum pulse
length, maximum pulse length, and pulse length exponent. |
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
public static final RandomPWM.Mode ALTERNATING
public static final RandomPWM.Mode NOISE
public static final RandomPWM.Mode PULSING
public static final RandomPWM.Mode SAW
public static final RandomPWM.Mode RAMPED_NOISE
public static final RandomPWM.Mode NOISE_ENVELOPE
protected RandomPWM.Mode mode
protected float targetVal
protected float baseVal
protected float valDiff
protected float count
protected float pulseLen
protected float minLength
protected float maxLength
protected float lengthExponent
protected float lengthDiff
public RandomPWM(AudioContext context, RandomPWM.Mode mode, float minl, float maxl)
context
- The audio context.mode
- The pulse mode; see setMode
.minl
- The minimum pulse length.maxl
- The maximum pulse length.public RandomPWM(AudioContext context, RandomPWM.Mode mode, float minl, float maxl, float lexp)
context
- The audio context.mode
- The pulse mode; see setMode
.minl
- The minimum pulse length.maxl
- The maximum pulse length.lexp
- The pulse length exponent.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 RandomPWM setParams(RandomPWM.Mode mode, float minl, float maxl, float lexp)
setMode
), minimum pulse
length, maximum pulse length, and pulse length exponent.mode
- The pulse mode.minl
- The minimum pulse length.maxl
- The maximum pulse length.lexp
- The pulse length exponent.public RandomPWM setParams(float minl, float maxl, float lexp)
minl
- The minimum pulse length.maxl
- The maximum pulse length.lexp
- The pulse length exponent.public RandomPWM setMinLength(float minl)
minl
- The minimum pulse length.public float getMinLength()
public RandomPWM setMaxLength(float maxl)
maxl
- The maximum pulse length.public float getMaxLength()
public RandomPWM setLengthExponent(float lexp)
lexp
- The pulse length exponent.public float getLengthExponent()
setLengthExponent(float)
public RandomPWM setMode(RandomPWM.Mode mode)
ALTERNATING
for pulses that alternate between -1 and 1.PULSING
for pulses that alternate between 0 and 1.NOISE
for pulses distributed randomly between -1 and 1.SAW
for random-length ramps between -1 and 1.RAMPED_NOISE
for random-length ramps between random
values.mode
- The pulse mode.public RandomPWM.Mode getMode()
setMode(Mode)
public DataBeadReceiver sendData(DataBead db)
sendData
in interface DataBeadReceiver
db
- The DataBead message.this
.public void messageReceived(Bead message)
Bead
messageReceived
in class Bead
message
- the messagepublic DataBead getParams()