Tone.Sampler
↳ EXTENDS Tone.InstrumentSampler 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
↳ inherited from
Tone.Instrument
∿
.volume
↝ Decibels #The volume of the output in decibels.
EXAMPLE
source.volume.value = -6;Methods
.triggerAttack ( )
#
pitch
The amount the sample should be repitched.
type:
Interval
default:
0
time
The time when the sample should start
type:
Time
default:
now
velocity
The velocity of the note
type:
NormalRange
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.
type:
Frequency
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.
type:
NormalRange
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");