Playing Notes and Melodies
index.html
When you want to play a sequence of notes, such as a melody, you need precise control over the timing of each note. Tone.js provides scheduling features that let you specify exactly when each note should start and how long it should play. This is done using the Tone.Transport object, which acts like a musical clock for your application.
Scheduling in Tone.js works by allowing you to set up events that will trigger at specific musical times. You can use time values like "0:0", "0:1", "0:2", etc., where each part represents measures, beats, and subdivisions. This makes it easy to line up notes in a way that matches musical timing, rather than having to calculate milliseconds yourself.
When you schedule a note, you provide a callback function that will be called at the right moment. Inside this function, you use methods like triggerAttackRelease to play the note for a certain duration. By listing out your melody as an array of note events and scheduling each one, you can create complex sequences that play back exactly as intended. The transport also lets you set the tempo and start or stop playback, making it a powerful tool for building musical applications in the browser.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 8.33
Playing Notes and Melodies
Swipe to show menu
index.html
When you want to play a sequence of notes, such as a melody, you need precise control over the timing of each note. Tone.js provides scheduling features that let you specify exactly when each note should start and how long it should play. This is done using the Tone.Transport object, which acts like a musical clock for your application.
Scheduling in Tone.js works by allowing you to set up events that will trigger at specific musical times. You can use time values like "0:0", "0:1", "0:2", etc., where each part represents measures, beats, and subdivisions. This makes it easy to line up notes in a way that matches musical timing, rather than having to calculate milliseconds yourself.
When you schedule a note, you provide a callback function that will be called at the right moment. Inside this function, you use methods like triggerAttackRelease to play the note for a certain duration. By listing out your melody as an array of note events and scheduling each one, you can create complex sequences that play back exactly as intended. The transport also lets you set the tempo and start or stop playback, making it a powerful tool for building musical applications in the browser.
Thanks for your feedback!