WLJS LogoWLJS Notebook

MusicPitch

MusicPitch[name]
MusicPitch[midiNumber]
MusicPitch[properties]

represents a musical pitch independently of its duration.

Named pitches may include an accidental and octave:

MusicPitch["F#4"]

MIDI pitch numbers are also accepted:

MusicPitch[60]

Useful properties include "Key", "Accidental", "Octave", "Name", "NameWithOctave", "MIDINumber", "Frequency", "PitchClass" and "CentDeviation".

pitch = MusicPitch["A4"];
pitch["Frequency"]
pitch["MIDINumber"]

Use a MusicPitch in notes, chords and scales:

Sound[MusicNote[MusicPitch["C#5"], 1/2]]

Add or subtract a MusicInterval to transpose a pitch:

MusicPitch["C4"] + MusicInterval["PerfectFifth"]

See the Wolfram Language reference for tuning and microtonal properties.