diff options
| author | mzed <github@mikezed.com> | 2017-11-20 12:52:45 +0000 |
|---|---|---|
| committer | mzed <github@mikezed.com> | 2017-11-20 12:52:45 +0000 |
| commit | 81939e5e629fd124595c05a56208176c3309974f (patch) | |
| tree | 922c3aa5fb2a9a80df1151898855cc957dc5f08c | |
| parent | fec9e22f85cb2e9a60d007319fbc06190ed71e55 (diff) | |
adding convert.ftom()
| -rw-r--r-- | maximilian.cpp | 6 | ||||
| -rwxr-xr-x | maximilian.h | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/maximilian.cpp b/maximilian.cpp index ee6d8de..74e4c61 100644 --- a/maximilian.cpp +++ b/maximilian.cpp @@ -1658,12 +1658,14 @@ void maxiDyn::setRatio(double ratioF) { ratio = ratioF; } - double convert::mtof(int midinote) { - return mtofarray[midinote]; } +int convert::ftom(double frequency) { + double baseFrequency = 440; + return round(12 * log2(frequency/baseFrequency)) + 69; +} template<> void maxiEnvelopeFollower::setAttack(double attackMS) { attack = pow( 0.01, 1.0 / ( attackMS * maxiSettings::sampleRate * 0.001 ) ); diff --git a/maximilian.h b/maximilian.h index 11089fe..8dc0d48 100755 --- a/maximilian.h +++ b/maximilian.h @@ -466,7 +466,8 @@ public: class convert { public: - double mtof(int midinote); + static double mtof(int midinote); + static int ftom(double frequency); }; |
