Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Playing Notes and Melodies | Creating Music with Code
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

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

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

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1
some-alt