

Tone.js runs an extensive test suite using mocha and chai with nearly 100% coverage. This wiki article has some suggestions related to performance for best practices. Tone.js makes extensive use of the native Web Audio Nodes such as the GainNode and WaveShaperNode for all signal processing, which enables Tone.js to work well on both desktop and mobile browsers. To use MIDI files, you’ll first need to convert them into a JSON format which Tone.js can understand using Midi. Or set your own AudioContext using tContext(audioContext). The AudioContext can be accessed at ntext. Tone.js creates an AudioContext when it loads and shims it for maximum browser compatibility using standardized-audio-context. rampTo ( " C2 ", 2 ) // start the oscillator for 2 seconds osc. value = " C4 " // ramp to "C2" over 2 seconds osc. The API is similar to the monophonic synths, except triggerRelease must be given a note or array of notes.Ĭonst osc = new Tone. To create a polyphonic synthesizer, use Tone.PolySynth, which accepts a monophonic synth as its first parameter and automatically handles the note allocation so you can pass in multiple notes. There are numerous synths to choose from including Tone.FMSynth, Tone.AMSynth and Tone.NoiseSynth.Īll of these instruments are monophonic (single voice) which means that they can only play one note at a time. Use this time value to schedule the events. Since Javascript callbacks are not precisely timed, the sample-accurate time of the event is passed into the callback function. start () // ramp up to 800 bpm over 10 seconds Tone.


start ( " 8n " ) // the loops start when the Transport is started Tone. toDestination () //play a note every quarter-note const loopA = new Tone. toDestination () const synthB = new Tone. create two monophonic synths const synthA = new Tone.
