note.frink


// Functions for converting frequencies to notes.

// The size of each note.

note[f] :=
{
   notesize = 2^(1/12)
   noteNames = ["C", "C#/Db", "D", "D#/Eb", "E", "F", "F#/Gb", "G", "G#/Ab", "A", "A#/Bb", "B"]
   
   A4 = 440 Hz
   C4 = A4 / (notesize^9)
   C0 = C4 / 2^4
   ratio = f/C0
   notes = ln[ratio]/ln[notesize]
   roundnotes = round[notes]
   octaves = floor[roundnotes/12]
   scale = roundnotes - (octaves * 12)
   return noteNames@scale + octaves
}


View or download note.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 14705 days, 19 hours, 53 minutes ago.