Last active
October 12, 2017 08:33
-
-
Save AkiyukiOkayasu/a6db8d809f647c891ada847ad370abad to your computer and use it in GitHub Desktop.
周波数(Hz)からMIDIノートナンバーに変換するための方法(C++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 周波数(Hz)からMIDIノートナンバーへの変換 | |
// Wikipediaの[MIDI tuning standard](https://en.wikipedia.org/wiki/MIDI_tuning_standard)を参照 | |
// A=440Hzの場合 | |
int freqToMidi(float freq) | |
{ | |
int midinote = std::nearbyint(69.0 + 12.0 * log2(freq / 440.0)); | |
return midinote; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment