|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.beadsproject.beads.core.Bead net.beadsproject.beads.core.UGen net.beadsproject.beads.ugens.SamplePlayer
public class SamplePlayer
SamplePlayer plays back a Sample
. Playback rate and loop points can be controlled by UGen
s. The playback point in the Sample
can also be directly controlled from UGen
to perform scrubbing. The player can be set to a number of different loop modes. If constructed with a Sample
argument, the number of outputs of SamplePlayer is determined by the number of channels of the Sample
. Sample
playback can use either linear or cubic interpolation.
Nested Class Summary | |
---|---|
static class |
SamplePlayer.InterpolationType
The Enum InterpolationType. |
static class |
SamplePlayer.LoopType
The Enum LoopType. |
Field Summary | |
---|---|
protected Sample |
buffer
The Sample. |
protected boolean |
forwards
Flag for alternating loop mode to determine if playback is in forward or reverse phase. |
protected SamplePlayer.InterpolationType |
interpolationType
The interpolation type. |
protected boolean |
killOnEnd
Flag to determine whether the SamplePlayer should kill itself when it gets to the end of the Sample. |
protected double |
lastChangedPosition
The last changed position, used to determine if the position envelope is in use. |
protected float |
loopCrossFade
The loop cross fade in milliseconds. |
protected float |
loopEnd
The loop end. |
protected UGen |
loopEndEnvelope
The loop end envelope. |
protected float |
loopStart
The loop start. |
protected UGen |
loopStartEnvelope
The loop start envelope. |
protected SamplePlayer.LoopType |
loopType
The loop type. |
protected double |
position
The position in milliseconds. |
protected UGen |
positionEnvelope
The position envelope. |
protected double |
positionIncrement
The millisecond position increment per sample. |
protected float |
rate
The rate. |
protected UGen |
rateEnvelope
The rate envelope. |
protected float |
sampleRate
The sample rate, determined by the Sample. |
protected boolean |
startLoop
Flag to determine whether playback starts at the beginning of the sample or at the beginning of the loop. |
Fields inherited from class net.beadsproject.beads.core.UGen |
---|
bufferSize, bufIn, bufOut, context, ins, outs |
Constructor Summary | |
---|---|
protected |
SamplePlayer(AudioContext context,
int outs)
Instantiates a new SamplePlayer with given number of outputs. |
|
SamplePlayer(AudioContext context,
Sample buffer)
Instantiates a new SamplePlayer with given Sample. |
Method Summary | |
---|---|
void |
calculateBuffer()
Called by the signal chain to update this UGen's ouput data. |
protected void |
calculateNextPosition(int i)
Used at each sample in the perform routine to determine the next playback position. |
Sample |
getBuffer()
Gets the Sample. |
SamplePlayer.InterpolationType |
getInterpolationType()
Gets the interpolation type. |
boolean |
getKillOnEnd()
Determines whether this SamplePlayer will kill itself at the end of the Sample it is playing. |
float |
getLoopCrossFade()
Gets the loop cross fade. |
UGen |
getLoopEndEnvelope()
Gets the loop end envelope. |
UGen |
getLoopStartEnvelope()
Gets the loop start envelope. |
SamplePlayer.LoopType |
getLoopType()
Gets the loop type. |
double |
getPosition()
Gets the playback position. |
UGen |
getPositionEnvelope()
Gets the position envelope. |
UGen |
getRateEnvelope()
Gets the rate envelope. |
float |
getSampleRate()
Gets the sample rate. |
boolean |
inLoop()
Determines whether the playback position is within the loop points. |
void |
reset()
Resets the position to the start of the Sample. |
void |
reTrigger()
Re trigger the SamplePlayer from the beginning. |
protected void |
setBuffer(Sample buffer)
Sets the Sample. |
void |
setInterpolationType(SamplePlayer.InterpolationType interpolationType)
Sets the interpolation type. |
void |
setKillOnEnd(boolean killOnEnd)
Sets/unsets option for SamplePlayer to kill itself when it reaches the end of the Sample it is playing. |
void |
setLoopCrossFade(float loopCrossFade)
Sets the loop cross fade. |
void |
setLoopEndEnvelope(UGen loopEndEnvelope)
Sets the loop end envelope. |
void |
setLoopPointsFraction(float start,
float end)
Sets both loop points to static values as fractions of the Sample length. |
void |
setLoopStartEnvelope(UGen loopStartEnvelope)
Sets the loop start envelope. |
void |
setLoopType(SamplePlayer.LoopType loopType)
Sets the loop type. |
void |
setPosition(double position)
Sets the playback position. |
void |
setPositionEnvelope(UGen positionEnvelope)
Sets the position envelope. |
void |
setRateEnvelope(UGen rateEnvelope)
Sets the rate envelope. |
void |
setToEnd()
Sets the playback position to the end of the Sample. |
void |
setToLoopStart()
Sets the playback position to the loop start point. |
void |
start(float msPosition)
Starts the sample at the given position. |
Methods inherited from class net.beadsproject.beads.core.UGen |
---|
addDependent, addInput, addInput, clearInputConnections, getContext, getIns, getNumberOfConnectedUGens, getOuts, getValue, getValue, noInputs, pause, printInputList, printOutBuffers, removeAllConnections, removeDependent, 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 |
---|
protected Sample buffer
protected float sampleRate
protected double position
protected double lastChangedPosition
protected UGen positionEnvelope
protected UGen rateEnvelope
protected double positionIncrement
AudioContext
's sample rate and the Sample
's sample rate.
protected boolean forwards
protected SamplePlayer.InterpolationType interpolationType
protected UGen loopStartEnvelope
protected UGen loopEndEnvelope
protected SamplePlayer.LoopType loopType
protected float loopCrossFade
protected boolean startLoop
protected boolean killOnEnd
protected float rate
protected float loopStart
protected float loopEnd
Constructor Detail |
---|
protected SamplePlayer(AudioContext context, int outs)
context
- the AudioContext.outs
- the number of outputs.public SamplePlayer(AudioContext context, Sample buffer)
context
- the AudioContext.buffer
- the Sample.Method Detail |
---|
protected void setBuffer(Sample buffer)
buffer
- the new Sample.public Sample getBuffer()
public void setToEnd()
public boolean inLoop()
public void setToLoopStart()
public void start(float msPosition)
msPosition
- the position in milliseconds.public void reset()
public double getPosition()
public void setPosition(double position)
position
- the new position in milliseconds.public UGen getPositionEnvelope()
public void setPositionEnvelope(UGen positionEnvelope)
positionEnvelope
- the new position envelope.public UGen getRateEnvelope()
public void setRateEnvelope(UGen rateEnvelope)
rateEnvelope
- the new rate envelope.public SamplePlayer.InterpolationType getInterpolationType()
public void setInterpolationType(SamplePlayer.InterpolationType interpolationType)
interpolationType
- the new interpolation type.public float getLoopCrossFade()
public void setLoopCrossFade(float loopCrossFade)
loopCrossFade
- the new loop cross fade in milliseconds.public UGen getLoopEndEnvelope()
public void setLoopEndEnvelope(UGen loopEndEnvelope)
loopEndEnvelope
- the new loop end envelope.public UGen getLoopStartEnvelope()
public void setLoopStartEnvelope(UGen loopStartEnvelope)
loopStartEnvelope
- the new loop start envelope.public void setLoopPointsFraction(float start, float end)
start
- the start value, as fraction of the Sample length.end
- the end value, as fraction of the Sample length.public SamplePlayer.LoopType getLoopType()
public void setLoopType(SamplePlayer.LoopType loopType)
loopType
- the new loop type.public float getSampleRate()
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
public void setKillOnEnd(boolean killOnEnd)
killOnEnd
- true to kill on end.public boolean getKillOnEnd()
public void reTrigger()
protected void calculateNextPosition(int i)
i
- the index within the buffer loop.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |