From 81939e5e629fd124595c05a56208176c3309974f Mon Sep 17 00:00:00 2001 From: mzed Date: Mon, 20 Nov 2017 12:52:45 +0000 Subject: adding convert.ftom() --- maximilian.cpp | 6 ++++-- 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); }; -- cgit v1.3