Tone.Sampler

↳ EXTENDS Tone.Instrument

Sampler wraps Tone.Player in an AmplitudeEnvelope.

CONSTRUCTOR

new Tone.Sampler (
url
, [
onload
] )
url

the url of the audio file

type: String
onload

The callback to invoke when the sample is loaded.

type: function
optional

DEFAULTS

{
onload : Tone.noOp ,
loop : false ,
reverse : false ,
envelope :
{
attack : 0.001 ,
decay : 0 ,
sustain : 1 ,
release : 0.1
}
}

EXAMPLE

var sampler = new Sampler("./audio/casio/A1.mp3", function(){
	//repitch the sample down a half step
	sampler.triggerAttack(-1);
}).toMaster();

Members

.envelope

↝ Tone.AmplitudeEnvelope #

The amplitude envelope.

</>

.loop

↝ number or string #

If the output sample should loop or not.

</>

.player

↝ Tone.Player #

The sample player.

</>

.reverse

↝ boolean #

The direction the buffer should play in

</>
↳ inherited from Tone.Instrument
∿

.volume

↝ Decibels #

The volume of the output in decibels.

EXAMPLE

source.volume.value = -6;
</>

Methods

.dispose ( )

#
↪ returns Tone.Sampler

this

Clean up.

</>

.triggerAttack ( )

#
pitch

The amount the sample should be repitched.

default: 0
time

The time when the sample should start

type: Time
default: now
velocity

The velocity of the note

default: 1
↪ returns Tone.Sampler

this

Trigger the start of the sample.

EXAMPLE

sampler.triggerAttack(0, "+0.1", 0.5);
</>

.triggerRelease ( )

#
time

The time when the note should release

type: Time
default: now
↪ returns Tone.Sampler

this

Start the release portion of the sample. Will stop the sample once the envelope has fully released.

EXAMPLE

sampler.triggerRelease();
</>
↳ inherited from Tone.Instrument

.triggerAttackRelease ( )

#
note

The note to trigger.

duration

How long the note should be held for before triggering the release.

type: Time
time

When the note should be triggered.

type: Time
default: now
velocity

The velocity the note should be triggered at.

default: 1
↪ returns Tone.Instrument

this

Trigger the attack and then the release after the duration.

EXAMPLE

//trigger "C4" for the duration of an 8th note
synth.triggerAttackRelease("C4", "8n");
</>
docs generated Sep 15 2019