|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.core.Bead
net.beadsproject.beads.core.UGen
net.beadsproject.beads.ugens.RandomPWM
public class RandomPWM
A simple random-length pulse wave modulator. This UGen generates constant
pulses of lengths randomly distributed between a minimum length and a maximum
length (specified in samples). Additionally, the distribution of the randomly
controlled by setting the pulse length exponent parameter (see
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen |
---|
UGen.OutputInitializationRegime, UGen.OutputPauseRegime |
Field Summary | |
---|---|
static int |
ALTERNATING
|
protected float |
baseVal
|
protected float |
count
|
protected float |
lengthDiff
|
protected float |
lengthExponent
|
protected float |
maxLength
|
protected float |
minLength
|
protected int |
mode
|
static int |
NOISE
|
protected float |
pulseLen
|
static int |
PULSING
|
static int |
RAMPED_NOISE
|
static int |
SAW
|
protected float |
targetVal
|
protected float |
valDiff
|
Fields inherited from class net.beadsproject.beads.core.UGen |
---|
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs |
Constructor Summary | |
---|---|
RandomPWM(AudioContext context,
int mode,
float minl,
float maxl,
float lexp)
Constructor. |
Method Summary | |
---|---|
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. |
int |
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 (floats only). |
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(int 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(int mode,
float minl,
float maxl,
float lexp)
Sets the pulse mode (see setMode ), minimum pulse
length, maximum pulse length, and pulse length exponent. |
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, setKillListener, setName, start, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ALTERNATING
public static final int NOISE
public static final int PULSING
public static final int SAW
public static final int RAMPED_NOISE
protected int 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
Constructor Detail |
---|
public RandomPWM(AudioContext context, int 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.Method Detail |
---|
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(int 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(int 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 int getMode()
setMode(int)
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |