Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Playing Notes and Melodies | Creating Music with Code
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
JavaScript Audio Creation with Tone.js

bookPlaying Notes and Melodies

index.html

index.html

copy

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.

question mark

In Tone.js, what is the main purpose of scheduling note playback?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

bookPlaying Notes and Melodies

Desliza para mostrar el menú

index.html

index.html

copy

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.

question mark

In Tone.js, what is the main purpose of scheduling note playback?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1
some-alt