Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära 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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 1

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookPlaying Notes and Melodies

Svep för att visa menyn

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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 1
some-alt