diff --git a/Open_Theremin_V3/application.cpp b/Open_Theremin_V3/application.cpp index c6c9b1f..adca14b 100644 --- a/Open_Theremin_V3/application.cpp +++ b/Open_Theremin_V3/application.cpp @@ -549,21 +549,28 @@ void Application::midi_application () delta_loop_cc_val = (double)new_midi_loop_cc_val - (double)old_midi_loop_cc_val; // Calculate log freq - if (vPointerIncrement < 18) + if ((vPointerIncrement < 18) || (vPointerIncrement > 65518)) { - // Highest note + // Lowest note double_log_freq = 0; } - else if (vPointerIncrement > 26315) + else if ((vPointerIncrement > 26315) && (vPointerIncrement < 39221)) { - // Lowest note + // Highest note double_log_freq = 127; } - else + else if (vPointerIncrement < 32768) { + // Positive frequencies // Find note in the playing range double_log_freq = (log (vPointerIncrement/17.152) / 0.057762265); // Precise note played in the logaritmic scale } + else + { + // Negative frequencies + // Find note in the playing range + double_log_freq = (log ((65535-vPointerIncrement+1)/17.152) / 0.057762265); // Precise note played in the logaritmic scale + } // Calculate rod antena cc value for midi new_midi_rod_cc_val = round (double_log_freq);