Pass in an object which maps the note's pitch or midi value to the file, then you can play the tone and stop 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.
You can an instance of the music object when you need it like this:
You can find a few instrument samples(check samples folder): sampler.PlayTone(notes, time, velocity)
Trigger the play of the note. Velocity optional default 1
note: The note to play.
time: When the note should be play.
velocity: The velocity scaler determines how "loud" the note will be played.
Trigger the play of the note after stop.
note: The note to play.
duration: How long the note should be held for before play the stop. This value must be greater than 0.
time: When the note should be play.
velocity: The velocity the note should be play at.
Stop the note portion of the envelope.
time: If no time is given, the stop happens immediatly.
When PlayTone is called, the attack time is the amount of time it takes for the envelope to reach it's maximum value.
The volume of the output in decibels.
After StopTone is called, the envelope's value will fall to it's miminum value over the duration of the release time.
Set multiple properties at once with an object.
Return sampler name.
Get the object's attributes.
Clean up.
Return Tone.Sampler class from Tonejs