package util import "math" // Return the frequency of a given MIDI note number. func NoteFreq(n float64) float64 { return (math.Pow(2, (n-69)/12)) * 440 } // Return the midi note number for the given frequency. func FreqNote(f float64) float64 { return 12*math.Log2(f/440) + 69 } // Return the one-cent change in frequency at the given frequency. func CentDeltaFreq(f float64) float64 { return f * (math.Pow(2, 1/1200.0) - 1) }