This tutorial demonstrates basic music concepts in JavaScript. All code on this page is MIT licensed.
To follow along, install the following package:
npm install go-music
The source code can be found here.
A note is one tone played at a single pitch. When you strike a piano key, or pluck a guitar string, you are playing a note.
Notes have letter names, like A, B, C, D, E, F, G.
Using our JS library, you can learn the relationships between the notes:
showNote('A');
Here’s a fun website where you can explore notes: https://learningmusic.ableton.com/notes-and-scales/notes-and-scales.html
showChord('C major');
showChord('C major 1st inversion');
showChord('A minor');
An interval is the distance between two notes.
showInterval('C', 'A');
A staff is a set of horizontal lines and spaces that represent music.
Here is an example staff showing four chords to be played in sequence:
let s = new Staff();
s.addClef('treble');
s.addChord('C4', 'F4', 'A4').withDuration(1/4);
s.addChord('C4', 'E4', 'Bb4').withDuration(1/4);
s.addChord('C4', 'E4', 'G4').withDuration(1/4);
s.addChord('C4', 'F#4', 'A4').withDuration(1/4);
showStaff(s);