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?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  1

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 2.  1
some-alt