Note API

The Note API provides functionality to convert music notes into their respective MIDI code and/or their frequency in Hertz, among other things. It it used in combination with computer.beep and note blocks (using OpenComponents).

  • note.midi(n: number or string): number
    Converts a note in string form (e.g. A#4 or Gb3, see below) or a given frequency into the respective MIDI code
  • note.freq(n: number or string): number
    Converts a note in string form (e.g. A#4) or a given MIDI code into the respective frequency
  • note.name(n: number): string
    Converts a MIDI value back into a string; if you have a frequency to convert, just use note.name(note.midi(frequency))
  • note.ticks(n: number): number
    Converts note block ticks (0-24) into MIDI code (34-58, respectively) and vice-versa. Useful for use with Note Blocks and OpenComponents
  • note.play(tone: string or number,duration: number)
    Plays a note from a string or MIDI code via computer.beep with the specified duration

Available notes

The available string names, their respective MIDI code and their frequency are shown here:

NameMIDI codeFrequency
A02127.5000
A#0/Bb02229.1352
B02330.8677
C12432.7032
C#1/Db12534.6478
D12636.7081
D#1/Eb12738.8909
E12841.2034
F12943.6535
F#1/Gb13046.2493
G13148.9994
G#1/Ab13251.9131
A13355.0000
A#1/Bb13458.2705
B13561.7354
C23665.4064
C#2/Db23769.2957
D23873.4162
D#2/Eb23977.7817
E24082.4069
F24187.3071
F#2/Gb24292.4986
G24397.9989
G#2/Ab244103.826
A245110.000
A#2/Bb246116.541
B247123.471
C348130.813
C#3/Db349138.591
D350146.832
D#3/Eb351155.563
E352164.814
F353174.614
F#3/Gb354184.997
G355195.998
G#3/Ab356207.652
A357220.000
A#3/Bb358233.082
B359246.942
C460261.626
C#4/Db461277.183
D462293.665
D#4/Eb463311.127
E464329.628
F465349.228
F#4/Gb466369.994
G467391.995
G#4/Ab468415.305
A469440.000
A#4/Bb470466.164
B471493.883
C572523.251
C#5/Db573554.365
D574587.330
D#5/Eb575622.254
E576659.255
F577698.456
F#5/Gb578739.989
G579783.991
G#5/Ab580830.609
A581880.000
A#5/Bb582932.328
B583987.767
C6841046.50
C#6/Db6851108.73
D6861174.66
D#6/Eb6871244.51
E6881318.51
F6891396.91
F#6/Gb6901479.98
G6911567.98
G#6/Ab6921661.22
A6931760.00
A#6/Bb6941864.66
B6951975.53

Contents