Frequency to/from MIDI formulae

(%i2) log2(x):=log(x)/log(2)                                                    
                                          log(x)                                
(%o2)                          log2(x) := ------                                
                                          log(2)                                
(%i3) midi_number(freq):=69+12*log2(freq/440)                                   
                                                      freq                      
(%o3)               midi_number(freq) := 69 + 12 log2(----)                     
                                                      440                       
(%i4) midi2freq(m):=440*2^((m-69)/12)                                           
                                               m - 69                           
                                               ------                           
                                                 12                             
(%o4)                     midi2freq(m) := 440 2                                 

Middle C has MIDI number 60.

(%i6) midi2freq(60),numer;                                                      
(%o6)                          261.6255653005986                                

Frequency 440 Hz corresponds with MIDI number 69

(%i8) midi_number(440),numer;                                                   
(%o8)                                69.0                                       

Leave a comment

Your email address will not be published. Required fields are marked *