Lesson 7 of 15
Transposition
Transposition
Transposing means shifting all notes up or down by the same number of semitones, preserving the shape of a melody or chord.
Why Transpose?
- Change the key of a song to suit a singer's range
- Move a chord up or down the neck of a guitar
- Shift a melody to fit a different instrument
The Formula
For each note in an array:
transposed[i] = notes[i] + steps
Example: C Major → D Major (+2 semitones)
C major: [60, 62, 64, 65, 67, 69, 71, 72]
D major: [62, 64, 66, 67, 69, 71, 73, 74]
Negative steps transpose down.
Your Task
Implement transpose(notes, steps) that shifts all notes by steps semitones.
Run your code to hear C major and F major (transposed up 5) back to back.
Web Audio API loading...
Loading...
Click "Run" to execute your code.