Tone.GrainPlayer

↳ EXTENDS Tone

Tone.GrainPlayer implements granular synthesis. Granular Synthesis enables you to adjust pitch and playback rate independently. The grainSize is the amount of time each small chunk of audio is played for and the overlap is the amount of crossfading transition time between successive grains.

CONSTRUCTOR

new Tone.GrainPlayer (
url
, [
callback
] )
url

The url to load, or the Tone.Buffer to play.

type: String or Tone.Buffer
callback

The callback to invoke after the url is loaded.

type: function
optional

DEFAULTS

{
onload : Tone.noOp ,
overlap : 0.1 ,
grainSize : 0.2 ,
drift : 0 ,
playbackRate : 1 ,
detune : 0 ,
loop : false ,
loopStart : 0 ,
loopEnd : 0 ,
reverse : false
}

Members

.reverse

↝ boolean #

The direction the buffer should play in

</>

.detune

↝ Cents #

Adjust the pitch independently of the playbackRate.

</>

.drift

↝ Time #

The amount of time randomly added or subtracted from the grain’s offset

</>

.grainSize

↝ Time #

The size of each chunk of audio that the buffer is chopped into and played back at.

</>

.loopEnd

↝ Time #

The loop end time.

</>

.loopStart

↝ Time #

The loop start time.

</>

.overlap

↝ Time #

This is the duration of the cross-fade between sucessive grains.

</>

.playbackRate

↝ Positive #

The playback rate of the sample

</>

.buffer

↝ Tone.Buffer #

The audio buffer belonging to the player.

</>

Methods

.dispose ( )

#
↪ returns Tone.GrainPlayer

this

Clean up

</>

.scrub ( )

#
offset

The offset to jump to.

type: Time
time

When to make the jump.

type: Time
optional
↪ returns

Jump to a specific time and play it.

</>

.start ( )

#
startTime

When the player should start.

type: Time
default: now
offset

The offset from the beginning of the sample to start at.

type: Time
default: 0
duration

How long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset)

type: Time
optional
↪ returns Tone.GrainPlayer

this

Play the buffer at the given startTime. Optionally add an offset and/or duration which will play the buffer from a position within the buffer for the given duration.

</>
docs generated Sep 15 2019