Lesson 9 of 15
Note Durations
Note Values
Western music notation divides beats into standard note values. At a given BPM, each note value has a precise duration in seconds.
Note Values
| Note | Type | Beats | Formula |
|---|---|---|---|
| π | Whole | 4 | 4 Γ beat |
| π π ₯ | Half | 2 | 2 Γ beat |
| β© | Quarter | 1 | 1 Γ beat |
| βͺ | Eighth | Β½ | Β½ Γ beat |
| β¬ | Sixteenth | ΒΌ | ΒΌ Γ beat |
Formula
noteDuration(bpm, noteType) = 60 / bpm Γ (4 / noteType)
Where noteType is 1 (whole), 2 (half), 4 (quarter), 8 (eighth), or 16 (sixteenth).
Example at 120 BPM
Quarter (4): 60/120 Γ (4/4) = 0.5000 s
Eighth (8): 60/120 Γ (4/8) = 0.2500 s
Sixteenth (16): 60/120 Γ (4/16) = 0.1250 s
Your Task
Implement noteDuration(bpm, noteType) returning the duration in seconds.
Run your code to hear quarter notes followed by eighth notes.
Web Audio API loading...
Loading...
Click "Run" to execute your code.