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.EnvelopeType, SamplePlayer.InterpolationType, SamplePlayer.LoopType
 
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
 
Field Summary
protected  float pitch
          The pitch, bound to the pitch envelope.
 
Fields inherited from class net.beadsproject.beads.ugens.SamplePlayer
ADAPTIVE_INTERP_HIGH_THRESH, ADAPTIVE_INTERP_LOW_THRESH, envelopeType, forwards, frame, interpolationType, killOnEnd, loopCrossFade, loopEnd, loopEndEnvelope, loopStart, loopStartEnvelope, loopType, position, positionEnvelope, positionIncrement, rate, rateEnvelope, sample, startLoop
 
Fields inherited from class net.beadsproject.beads.core.UGen
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
 
Constructor Summary
GranularSamplePlayer(AudioContext context, int outs)
          Instantiates a new GranularSamplePlayer.
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()
          Deprecated. Use getGrainIntervalUGen() instead.
 UGen getGrainIntervalUGen()
          Gets the grain interval UGen.
 UGen getGrainSizeEnvelope()
          Deprecated. Use getGrainSizeUGen() instead.
 UGen getGrainSizeUGen()
          Gets the grain size UGen.
 UGen getPitchEnvelope()
          Deprecated. use getPitchUGen().
 UGen getPitchUGen()
          Gets the pitch UGen.
 UGen getRandomnessEnvelope()
          Deprecated. Use getRandomnessUGen() instead.
 UGen getRandomnessUGen()
          Gets the randomness UGen.
 UGen getRandomPanEnvelope()
          Deprecated. Use getRandomPanUGen() instead.
 UGen getRandomPanUGen()
          Gets the random pan UGen.
 Buffer getWindow()
           
 void setBuffer(Sample buffer)
          Deprecated. Use setSample(Sample) instead.
 void setGrainInterval(UGen grainIntervalUGen)
          Sets the grain interval UGen.
 void setGrainIntervalEnvelope(UGen grainIntervalEnvelope)
          Deprecated. Use setGrainInterval(UGen) instead.
 void setGrainSize(UGen grainSizeUGen)
          Sets the grain size UGen.
 void setGrainSizeEnvelope(UGen grainSizeEnvelope)
          Deprecated. Use setGrainSize(UGen) instead.
 void setPitch(UGen pitchUGen)
          Sets the pitch UGen.
 void setPitchEnvelope(UGen pitchEnvelope)
          Deprecated. Use setPitch(UGen) instead.
 void setRandomness(UGen randomnessUGen)
          Sets the randomness UGen.
 void setRandomnessEnvelope(UGen randomnessEnvelope)
          Deprecated. Use setRandomness(UGen) instead.
 void setRandomPan(UGen randomPanEnvelope)
           
 void setRandomPanEnvelope(UGen randomPanEnvelope)
          Deprecated. Use setRandomPan(UGen) instead.
 void setSample(Sample buffer)
          Sets the Sample.
 void setWindow(Buffer window)
           
 void start()
          Shortcut for pause(false).
 
Methods inherited from class net.beadsproject.beads.ugens.SamplePlayer
calculateNextPosition, getBuffer, getEndListener, getEnvelopeType, getInterpolationType, getKillOnEnd, getLoopCrossFade, getLoopEndEnvelope, getLoopEndUGen, getLoopStartEnvelope, getLoopStartUGen, getLoopType, getPosition, getPositionEnvelope, getPositionUGen, getRateEnvelope, getRateUGen, getSample, getSampleRate, inLoop, reset, reTrigger, setEndListener, setEnvelopeType, setInterpolationType, setKillOnEnd, setLoopCrossFade, setLoopEnd, setLoopEndEnvelope, setLoopPointsFraction, setLoopStart, setLoopStartEnvelope, setLoopType, setPosition, setPosition, setPositionEnvelope, setRate, setRateEnvelope, setToEnd, setToLoopStart, start
 
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, 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,
                            int outs)
Instantiates a new GranularSamplePlayer.

Parameters:
context - the AudioContext.
outs - the number of outputs.

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

@Deprecated
public UGen getPitchEnvelope()
Deprecated. use getPitchUGen().

Gets the pitch envelope.

Overrides:
getPitchEnvelope in class SamplePlayer
Returns:
the pitch envelope.

getPitchUGen

public UGen getPitchUGen()
Gets the pitch UGen.

Overrides:
getPitchUGen in class SamplePlayer
Returns:
the pitch UGen.

setPitchEnvelope

@Deprecated
public void setPitchEnvelope(UGen pitchEnvelope)
Deprecated. Use setPitch(UGen) instead.

Sets the pitch envelope.

Overrides:
setPitchEnvelope in class SamplePlayer
Parameters:
pitchEnvelope - the new pitch envelope.

setPitch

public void setPitch(UGen pitchUGen)
Sets the pitch UGen.

Overrides:
setPitch in class SamplePlayer
Parameters:
pitchUGen - the new pitch Ugen.

getGrainIntervalEnvelope

@Deprecated
public UGen getGrainIntervalEnvelope()
Deprecated. Use getGrainIntervalUGen() instead.

Gets the grain interval envelope.

Returns:
the grain interval envelope.

getGrainIntervalUGen

public UGen getGrainIntervalUGen()
Gets the grain interval UGen.

Returns:
the grain interval UGen.

setGrainIntervalEnvelope

@Deprecated
public void setGrainIntervalEnvelope(UGen grainIntervalEnvelope)
Deprecated. Use setGrainInterval(UGen) instead.

Sets the grain interval envelope.

Parameters:
grainIntervalEnvelope - the new grain interval envelope.

setGrainInterval

public void setGrainInterval(UGen grainIntervalUGen)
Sets the grain interval UGen.

Parameters:
grainIntervalUGen - the new grain interval UGen.

getGrainSizeEnvelope

@Deprecated
public UGen getGrainSizeEnvelope()
Deprecated. Use getGrainSizeUGen() instead.

Gets the grain size envelope.

Returns:
the grain size envelope.

getGrainSizeUGen

public UGen getGrainSizeUGen()
Gets the grain size UGen.

Returns:
the grain size UGen.

setGrainSizeEnvelope

@Deprecated
public void setGrainSizeEnvelope(UGen grainSizeEnvelope)
Deprecated. Use setGrainSize(UGen) instead.

Sets the grain size envelope.

Parameters:
grainSizeEnvelope - the new grain size envelope.

setGrainSize

public void setGrainSize(UGen grainSizeUGen)
Sets the grain size UGen.

Parameters:
grainSizeUGen - the new grain size UGen.

getWindow

public Buffer getWindow()

setWindow

public void setWindow(Buffer window)

getRandomnessEnvelope

@Deprecated
public UGen getRandomnessEnvelope()
Deprecated. Use getRandomnessUGen() instead.

Gets the randomness envelope.

Returns:
the randomness envelope.

getRandomnessUGen

public UGen getRandomnessUGen()
Gets the randomness UGen.

Returns:
the randomness UGen.

setRandomnessEnvelope

@Deprecated
public void setRandomnessEnvelope(UGen randomnessEnvelope)
Deprecated. Use setRandomness(UGen) instead.

Sets the randomness envelope.

Parameters:
randomnessEnvelope - the new randomness envelope.

setRandomness

public void setRandomness(UGen randomnessUGen)
Sets the randomness UGen.

Parameters:
randomnessUGen - the new randomness UGen.

getRandomPanEnvelope

@Deprecated
public UGen getRandomPanEnvelope()
Deprecated. Use getRandomPanUGen() instead.

Returns:
the random pan envelope.

getRandomPanUGen

public UGen getRandomPanUGen()
Gets the random pan UGen.

Returns:
the random pan Ugen.

setRandomPanEnvelope

@Deprecated
public void setRandomPanEnvelope(UGen randomPanEnvelope)
Deprecated. Use setRandomPan(UGen) instead.

Parameters:
randomPanEnvelope -

setRandomPan

public void setRandomPan(UGen randomPanEnvelope)

setBuffer

@Deprecated
public void setBuffer(Sample buffer)
Deprecated. Use setSample(Sample) instead.

Overrides:
setBuffer in class SamplePlayer

setSample

public void setSample(Sample buffer)
Description copied from class: SamplePlayer
Sets the Sample.

Overrides:
setSample in class SamplePlayer

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.