diff --git a/Open_Theremin_V3/application.cpp b/Open_Theremin_V3/application.cpp index e692342..278034f 100644 --- a/Open_Theremin_V3/application.cpp +++ b/Open_Theremin_V3/application.cpp @@ -33,8 +33,9 @@ static uint8_t old_midi_loop_cc_val =0; static uint8_t midi_velocity = 0; static uint8_t loop_hand_pos = 0; -static uint8_t new_midi_rod_cc_val =0; -static uint8_t old_midi_rod_cc_val =0; + +static uint16_t new_midi_rod_cc_val =0; +static uint16_t old_midi_rod_cc_val =0; static uint16_t new_midi_bend =0; static uint16_t old_midi_bend = 0; @@ -55,6 +56,7 @@ static uint8_t flag_legato_on = 1; static uint8_t flag_pitch_bend_on = 1; static uint8_t loop_midi_cc = 7; static uint8_t rod_midi_cc = 255; +static uint8_t rod_midi_cc_lo = 255; // tweakable paramameters #define VELOCITY_SENS 9 // How easy it is to reach highest velocity (127). Something betwen 5 and 12. @@ -518,8 +520,8 @@ void Application::delay_NOP(unsigned long time) { void Application::midi_setup() { // Set MIDI baud rate: - Serial.begin(115200); // Baudrate for midi to serial. Use a serial to midi router http://projectgus.github.com/hairless-midiserial/ - //Serial.begin(31250); // Baudrate for real midi. Use din connection https://www.arduino.cc/en/Tutorial/Midi or HIDUINO https://github.com/ddiakopoulos/hiduino + //Serial.begin(115200); // Baudrate for midi to serial. Use a serial to midi router http://projectgus.github.com/hairless-midiserial/ + Serial.begin(31250); // Baudrate for real midi. Use din connection https://www.arduino.cc/en/Tutorial/Midi or HIDUINO https://github.com/ddiakopoulos/hiduino _midistate = MIDI_SILENT; } @@ -577,7 +579,7 @@ void Application::midi_application () } // Calculate rod antena cc value for midi - new_midi_rod_cc_val = round (double_log_freq); + new_midi_rod_cc_val = round (double_log_freq * 128); // 14 bit value ! // State machine for MIDI switch (_midistate) @@ -595,9 +597,16 @@ void Application::midi_application () } // Always refresh midi rod antena cc if applicable. - if ((rod_midi_cc != 255) && (new_midi_rod_cc_val != old_midi_rod_cc_val)) + if (new_midi_rod_cc_val != old_midi_rod_cc_val) { - midi_msg_send(midi_channel, 0xB0, rod_midi_cc, new_midi_rod_cc_val); + if (rod_midi_cc != 255) + { + if (rod_midi_cc_lo != 255) + { + midi_msg_send(midi_channel, 0xB0, rod_midi_cc_lo, (uint8_t)(new_midi_rod_cc_val & 0x007F)); + } + midi_msg_send(midi_channel, 0xB0, rod_midi_cc, (uint8_t)(new_midi_rod_cc_val >> 7)); + } old_midi_rod_cc_val = new_midi_rod_cc_val; } else @@ -656,9 +665,16 @@ void Application::midi_application () } // Always refresh midi rod antena cc if applicable. - if ((rod_midi_cc != 255) && (new_midi_rod_cc_val != old_midi_rod_cc_val)) + if (new_midi_rod_cc_val != old_midi_rod_cc_val) { - midi_msg_send(midi_channel, 0xB0, rod_midi_cc, new_midi_rod_cc_val); + if (rod_midi_cc != 255) + { + if (rod_midi_cc_lo != 255) + { + midi_msg_send(midi_channel, 0xB0, rod_midi_cc_lo, (uint8_t)(new_midi_rod_cc_val & 0x007F)); + } + midi_msg_send(midi_channel, 0xB0, rod_midi_cc, (uint8_t)(new_midi_rod_cc_val >> 7)); + } old_midi_rod_cc_val = new_midi_rod_cc_val; } else @@ -900,21 +916,26 @@ void Application::set_parameters () { case 0: rod_midi_cc = 255; // Nothing + rod_midi_cc_lo = 255; // Nothing break; case 1: case 2: rod_midi_cc = 8; // Balance + rod_midi_cc_lo = 40; // Balance least significant bits break; case 3: case 4: rod_midi_cc = 10; // Pan + rod_midi_cc_lo = 42; // Pan least significant bits break; case 5: case 6: rod_midi_cc = 16; // Ribbon Controler + rod_midi_cc_lo = 48; // Ribbon Controler least significant bits break; default: rod_midi_cc = 74; // Cutoff (exists of both loop and rod) + rod_midi_cc_lo = 255; // No least significant bits break; } break; diff --git a/Quick guide open theremin midi.bmp b/Quick guide open theremin midi.bmp index 072e7bb..e9e6b79 100644 Binary files a/Quick guide open theremin midi.bmp and b/Quick guide open theremin midi.bmp differ diff --git a/README.md b/README.md index e2edb2c..d0954d7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -## Open Theremin V3 with MIDI interface control software V2.3 for Arduino UNO +## Open Theremin V3 with MIDI interface control software V2.4 for Arduino UNO Based on Arduino UNO Software for the Open.Theremin version 3.0 Copyright (C) 2010-2016 by Urs Gaudenz https://github.com/GaudiLabs/OpenTheremin_V3 -This Open Theremin V3 with MIDI version V2.3 also takes into account +This Open Theremin V3 with MIDI version V2.4 also takes into account Changes added in Open.Theremin version 3.1 (all by @Theremingenieur): Fix a wavetable addressing issue (found by @miguelfreitas) @@ -16,6 +16,8 @@ Changes added in Open.Theremin version 3.1 (all by @Theremingenieur): Pitch Bend Range choice is also extended (Allows 4 octaves Bend) +MIDI CC from Pitch antenna (Rod) have 14 Bit resolution when applicable. Example of application: you can create a software synth controled by CC7 for volume and CC16 (MSB) - CC48 (LSB) for pitch without using Note On/Off and Pitch Bend messages. + Urs also made a very clear presentation of the MIDI feature on his website: http://www.gaudi.ch/OpenTheremin/index.php?option=com_content&view=article&id=200&Itemid=121, many thanks ! ### Don't click on the files! @@ -97,7 +99,7 @@ Let's consider a Fade-in / Picth Variation / Fade-out sequence (I use right hand Maximum setting possible is recomended. 6. Volume trigger / Velocity sensitivity (how fast moves the volume loop's hand): 128 positions (0 to 127) 7. Rod antenna MIDI CC: 5 positions - (None, 8-Balance, 10-Pan, 16-Ribbon controler, 74-cutoff) + (None, 8-MSB/40-LSB-Balance, 10-MSB/42-LSB-Pan, 16-MSB/48-LSB-Ribbon controler, 74-cutoff) 14 Bit messages are sent in the following order: LSB (1st), MSB (2nd). 8. Loop antenna MIDI CC: 8 positions (1-Modulation, 7-Volume, 11-Expression, 71-Resonnance, 74-Cutoff, 91-Reverb, 93-Chorus, 95-Phaser)