net.beadsproject.beads.ugens
Class GranularSamplePlayer

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

public class GranularSamplePlayer
extends SamplePlayer

GranularSamplePlayer plays back a Sample using granular synthesis. GranularSamplePlayer inherits its main behaviour from SamplePlayer but replaces the direct Sample lookup with a granular process. UGens can be used to control playback rate, pitch, loop points, grain size, grain interval, grain randomness and position (this last case assumes that the playback rate is zero).

Author:
ollie
See Also:
Sample

Nested Class Summary
 
Nested classes/interfaces inherited from class net.beadsproject.beads.ugens.SamplePlayer
SamplePlayer.InterpolationType, SamplePlayer.LoopType
 
Field Summary
protected  float pitch
          The pitch, bound to the pitch envelope.
 
Fields inherited from class net.beadsproject.beads.ugens.SamplePlayer
buffer, forwards, interpolationType, killOnEnd, lastChangedPosition, loopCrossFade, loopEnd, loopEndEnvelope, loopStart, loopStartEnvelope, loopType, position, positionEnvelope, positionIncrement, rate, rateEnvelope, sampleRate, startLoop
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outs
 
Constructor Summary
GranularSamplePlayer(AudioContext context, Sample buffer)
          Instantiates a new GranularSamplePlayer.
 
Method Summary
 void calculateBuffer()
          Called by the signal chain to update this UGen's ouput data.
 float getAverageNumberOfGrains()
          Calculates the average number of Grains given the current grain size and grain interval.
 UGen getGrainIntervalEnvelope()
          Gets the grain interval envelope.
 UGen getGrainSizeEnvelope()
          Gets the grain size envelope.
 UGen getPitchEnvelope()
          Gets the pitch envelope.
 UGen getRandomnessEnvelope()
          Gets the randomness envelope.
 void setGrainIntervalEnvelope(UGen grainIntervalEnvelope)
          Sets the grain interval envelope.
 void setGrainSizeEnvelope(UGen grainSizeEnvelope)
          Sets the grain size envelope.
 void setPitchEnvelope(UGen pitchEnvelope)
          Sets the pitch envelope.
 void setRandomnessEnvelope(UGen randomnessEnvelope)
          Sets the randomness envelope.
 void start()
          Shortcut for pause(false).
 
Methods inherited from class net.beadsproject.beads.ugens.SamplePlayer
calculateNextPosition, getBuffer, getInterpolationType, getKillOnEnd, getLoopCrossFade, getLoopEndEnvelope, getLoopStartEnvelope, getLoopType, getPosition, getPositionEnvelope, getRateEnvelope, getSampleRate, inLoop, reset, reTrigger, setBuffer, setInterpolationType, setKillOnEnd, setLoopCrossFade, setLoopEndEnvelope, setLoopPointsFraction, setLoopStartEnvelope, setLoopType, setPosition, setPositionEnvelope, setRateEnvelope, setToEnd, setToLoopStart, start
 
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, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pitch

protected float pitch
The pitch, bound to the pitch envelope.

Constructor Detail

GranularSamplePlayer

public GranularSamplePlayer(AudioContext context,
                            Sample buffer)
Instantiates a new GranularSamplePlayer.

Parameters:
context - the AudioContext.
buffer - the Sample played by the GranularSamplePlayer.
Method Detail

getPitchEnvelope

public UGen getPitchEnvelope()
Gets the pitch envelope.

Returns:
the pitch envelope.

setPitchEnvelope

public void setPitchEnvelope(UGen pitchEnvelope)
Sets the pitch envelope.

Parameters:
pitchEnvelope - the new pitch envelope.

getGrainIntervalEnvelope

public UGen getGrainIntervalEnvelope()
Gets the grain interval envelope.

Returns:
the grain interval envelope.

setGrainIntervalEnvelope

public void setGrainIntervalEnvelope(UGen grainIntervalEnvelope)
Sets the grain interval envelope.

Parameters:
grainIntervalEnvelope - the new grain interval envelope.

getGrainSizeEnvelope

public UGen getGrainSizeEnvelope()
Gets the grain size envelope.

Returns:
the grain size envelope.

setGrainSizeEnvelope

public void setGrainSizeEnvelope(UGen grainSizeEnvelope)
Sets the grain size envelope.

Parameters:
grainSizeEnvelope - the new grain size envelope.

getRandomnessEnvelope

public UGen getRandomnessEnvelope()
Gets the randomness envelope.

Returns:
the randomness envelope.

setRandomnessEnvelope

public void setRandomnessEnvelope(UGen randomnessEnvelope)
Sets the randomness envelope.

Parameters:
randomnessEnvelope - the new randomness envelope.

start

public void start()
Description copied from class: Bead
Shortcut for pause(false).

Overrides:
start in class Bead

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.

Overrides:
calculateBuffer in class SamplePlayer

getAverageNumberOfGrains

public float getAverageNumberOfGrains()
Calculates the average number of Grains given the current grain size and grain interval.

Returns:
the average number of Grains.