Tone.Sampler
↳ EXTENDS Tone.InstrumentAutomatically interpolates between a set of pitched samples. Pass in an object which maps the note’s pitch or midi value to the url, then you can trigger the attack and release of that note like other instruments. By automatically repitching the samples, it is possible to play pitches which were not explicitly included which can save loading time. For sample or buffer playback where repitching is not necessary, use Tone.Player.
CONSTRUCTOR
new Tone.Sampler (An object of samples mapping either Midi Note Numbers or Scientific Pitch Notation to the url of that sample.
The callback to invoke when all of the samples are loaded.
The root URL of all of the samples, which is prepended to all the URLs.
DEFAULTS
EXAMPLE
Members
.context
↝ Tone.Context READONLY #Get the audio context belonging to this instance.
.numberOfOutputs
↝ Number READONLY #The number of outputs coming out of the AudioNode.
.numberOfInputs
↝ Number READONLY #The number of inputs feeding into the AudioNode. For source nodes, this will be 0.
.channelCount
↝ Number READONLY #channelCount is the number of channels used when up-mixing and down-mixing connections to any inputs to the node. The default value is 2 except for specific nodes where its value is specially determined.
.channelCountMode
↝ String READONLY #channelCountMode determines how channels will be counted when up-mixing and down-mixing connections to any inputs to the node. The default value is “max”. This attribute has no effect for nodes with no inputs.
.channelInterpretation
↝ String READONLY #channelInterpretation determines how individual channels will be treated when up-mixing and down-mixing connections to any inputs to the node. The default value is “speakers”.
.volume
↝ Decibels #The volume of the output in decibels.
EXAMPLE
Methods
.add ( )
#Either the url of the bufer, or a buffer which will be added with the given name.
The callback to invoke when the url is loaded.
Add a note to the sampler.
.releaseAll ( )
#When to release the notes.
this
Release all currently active notes.
.sync ( )
#this
Sync the instrument to the Transport. All subsequent calls of triggerAttack and triggerRelease will be scheduled along the transport.
EXAMPLE
.triggerAttack ( )
#When to play the note
The velocity to play the sample back.
this
.triggerAttackRelease ( )
#When to start the attack
The velocity of the attack
this
Invoke the attack phase, then after the duration, invoke the release.
.triggerRelease ( )
#When to release the note.
this
.chain ( )
#this
Connect the output of this node to the rest of the nodes in series.
EXAMPLE
.connect ( )
#optionally which output to connect from
optionally which input to connect to
this
connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
.disconnect ( )
#Either the output index to disconnect if the output is an array, or the node to disconnect from.
this
disconnect the output
.fan ( )
#this
connect the output of this node to the rest of the nodes in parallel.
.toMaster ( )
#this
Connect ‘this’ to the master output. Shorthand for this.connect(Tone.Master)
EXAMPLE
.unsync ( )
#this
Unsync the instrument from the Transport