Translanting MIDI Notes to frequencies in the diatonic scale using the central A (440hz) as reference

May 24th, 2008 by nictuku

One of the plug-ins that i'm programming for my GSoC project is a MIDI Note to frecuency and velocity translator.
Beyond the technical background of the problem, i'm writing down the theoretical aspects of it, nothing hard, but usefull to have as a reference for the future.

It's not even a mystery to know that to obtain the frequency of a note in the diatonic scale separated by n semitones from the reference frequency we can use the next formula:

$latex Freq_{Note} = Freq_{Ref} + 2^{(\frac{n}{12})}$

So, also knowing that MIDI notes are represented with integers, in which for consecutive notes have one semitone of difference, and that the 440hz A is the note 69 (so, 69 is A, 70 is A#, and so..), doing some simple replacements we have that:

$latex Freq_{Note} = Freq_{Ref} + 2^{(\frac{n-69}{12})}$

And this is just what we were looking for, (n-69 generates an offset from the reference note)
Now, only by replacing the reference frequency for the 440hz we obtain:

$latex Freq_{Nota} = 440hz + 2^{(\frac{n-69}{12})}$

Here I give you the C++ code that I used in the MIDINoteOutControlSender:

 
frequency = 440 * pow(2.0,(note-69.0)/12.0)

Hordia wrote last year on his blog the inverse formula to translate from fundamental frequencies to MIDI notes.

Bookmark and Share:

One Response to “Translanting MIDI Notes to frequencies in the diatonic scale using the central A (440hz) as reference”

  1. AudioResearchBlog » Blog Archive » Fundamental (in Hz) to a MIDI note Says:

    [...] Related post: nictuku’s inverse formula (from MIDI to Hz) in Translanting MIDI Notes to frequencies in the diatonic scale using the central A (440hz) as referenc… algorithms , audio , c++ , CLAM , english , GSoC2007 , math , midi , music theory , programming , [...]

Leave a Reply