Converting a Frequency to a Midi Note

Posted: December 3, 2012 in .NET

This is a C# method to convert a pitch or frequency to a midi note.
I am shifting detected frequencies to the nearest semi-tone before using this formula.


private double GetMidiNote(float freq)
{
return Math.Ceiling(69 + 12 * (Math.Log(freq/440, 2)));
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s