changeset 11:76344930dd84

Teensy code added <calibrate> tags removed commented println
author Fiore Martin <f.martin@qmul.ac.uk>
date Fri, 22 Jul 2016 14:30:58 +0200
parents 60003fd11ca6
children bd805377f6ab
files CollidoscopeTeensy/CollidoscopeTeensy_new.ino CollidoscopeTeensy/CollidoscopeTeensy_original.ino
diffstat 2 files changed, 17 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/CollidoscopeTeensy/CollidoscopeTeensy_new.ino	Tue Jul 19 11:43:37 2016 +0200
+++ b/CollidoscopeTeensy/CollidoscopeTeensy_new.ino	Fri Jul 22 14:30:58 2016 +0200
@@ -67,8 +67,6 @@
 //Default Values:
 const int  Enc_def = 64; //default selection length  
 int MIDI_led_state = LOW;
-//boolean reset1 = true;
-//boolean reset2 = true;
 
 ///////////////////////////////////////////////////
 // Interface Inputs
@@ -141,8 +139,8 @@
   button4.update();
 
   
-  uint16_t Jet1_new = analogRead(0); //read Wavejet/Rail 1
-  uint16_t Jet2_new = analogRead(1); //read Wavejet/Rail 2
+  uint16_t Jet1_new = analogRead(0);      //read Wavejet/Rail 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
+  uint16_t Jet2_new = analogRead(1);      //read Wavejet/Rail 2; ADJUST INPUT RANGE ACCORDING TO SENSOR    
   uint16_t filter1_new = analogRead(2);   //read filter Instrument 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
   uint16_t filter2_new = analogRead(4);   //read filter Instrument 2; ADJUST INPUT RANGE ACCORDING TO SENSOR  
 
@@ -199,30 +197,26 @@
  
  //Instrument 1 Controls//////////////////////////////////////  
  
- //Loop/Keymode Switch Instrument 1 
-   
+ //Loop/Keymode Switch Instrument 1    
  if (button1.risingEdge()) {   
-   //Serial.println("Loop mode");
    usbMIDI.sendControlChange(cc_play, 1, midi_chan_inst1);
  }
    
  if (button1.fallingEdge()) {   
-   //Serial.println("Keyboardmode mode");
    usbMIDI.sendControlChange(cc_play, 0, midi_chan_inst1);
  }
      
    
  //Record Instrument 1
  if (button2.fallingEdge()) {   
-   //Serial.println("RECORD! Instrument 1");
    usbMIDI.sendControlChange(cc_record, 1, midi_chan_inst1);
  }
 
  //send MIDI Wavejet 1 [Position Instrument 1]
+ //<calibrate>
  if (Jet1_new > Jet1_old+jitter_thresh || Jet1_new < Jet1_old-jitter_thresh) {
     
     int16_t midiVal = constrain( map(Jet1_new, 988, 121, 0, 149), 0, 149 );
-    // int16_t midiVal = constrain( map( Jet1_new, 23, 928, 0, 149 ), 0, 149 ); old collidoscope 
     if( midiVal != Jet1_old_MIDI ){
       Jet1_old_MIDI = midiVal;
       usbMIDI.sendPitchBend( midiVal, midi_chan_inst1 );
@@ -234,8 +228,8 @@
 
 
  //send MIDI Filter 1 [Filter Instrument 1]
-
- if ( filter1_new > filter1_old+jitter_thresh_short || filter1_new < filter1_old-jitter_thresh_short ) {         // maybe adding jitter threshold needed, see Jet1_new  
+ //<calibrate>
+ if ( filter1_new > filter1_old+jitter_thresh_short || filter1_new < filter1_old-jitter_thresh_short ) {
  
     int16_t midiVal = constrain( map(filter1_new, 145, 756, 0, 127), 0, 127 );
     if( midiVal != filter1_old_MIDI){
@@ -251,8 +245,6 @@
   //send MIDI Encoder 1 [Selection length Instrument 1]
   if (Enc1_new != Enc1_old) {
     Enc1_old = Enc1_new;
-    //Serial.println("Encoder 1: ");
-    //Serial.println(Enc1_new);
     usbMIDI.sendControlChange(cc_length, Enc1_new, midi_chan_inst1);
     digitalWrite(Pin_MIDIled, HIGH);
   }
@@ -260,8 +252,6 @@
   //send MIDI Encoder 3 [Duration Instrument 1]
   if (Enc3_new != Enc3_old) {
     Enc3_old = Enc3_new;
-    //Serial.println("Encoder 3: ");
-    //Serial.println(Enc3_new);
     usbMIDI.sendControlChange(cc_duration, Enc3_new, midi_chan_inst1);
     digitalWrite(Pin_MIDIled, HIGH);
   }
@@ -270,27 +260,22 @@
   //Instrument 2 Controls//////////////////////////////////////  
   
   //Loop/Keymode Switch Instrument 2
-   
   if (button3.risingEdge()) {   
-    //Serial.println("Loop mode");
     usbMIDI.sendControlChange(cc_play, 1, midi_chan_inst2);
   }
   
   if (button3.fallingEdge()) {   
-    //Serial.println("Keyboardmode mode");
     usbMIDI.sendControlChange(cc_play, 0, midi_chan_inst2);
   }
   
   //Record Instrument 2
   if (button4.fallingEdge()) {   
-    //Serial.println("RECORD! Instrument 2");
     usbMIDI.sendControlChange(cc_record, 1, midi_chan_inst2);
   }
 
   //send MIDI Wavejet 2 [Position Instrument 2]
-  
+  // <calibrate>
   if (Jet2_new > Jet2_old+jitter_thresh || Jet2_new < Jet2_old-jitter_thresh) {
-    //Serial.println("RECORD! Instrument 2");
     int16_t midiVal = constrain( map( Jet2_new, 109, 992, 149, 0 ), 0, 149 );
     if( midiVal != Jet2_old_MIDI ){
       Jet2_old_MIDI = midiVal;
@@ -301,11 +286,11 @@
     digitalWrite(Pin_MIDIled, HIGH);
   }
   
- //Serial.println(filter2_new);
-   if ( filter2_new > filter2_old+jitter_thresh_short || filter2_new < filter2_old-jitter_thresh_short ) {         // maybe adding jitter threshold needed, see Jet1_new  
+  //send MIDI Filter 2 [Filter Instrument 2]
+  //<calibrate>
+  if ( filter2_new > filter2_old+jitter_thresh_short || filter2_new < filter2_old-jitter_thresh_short ) {
     int16_t midiVal = constrain( map(filter2_new, 132, 700, 0, 127), 0, 127 );
     if( midiVal != filter2_old_MIDI){
-      //Serial.println( midiVal );
       filter2_old_MIDI = midiVal;
       usbMIDI.sendControlChange(cc_filter, midiVal, midi_chan_inst2);
     }
@@ -318,8 +303,6 @@
   //send MIDI Encoder 2 [Selection length Instrument 2]
   if (Enc2_new != Enc2_old) {
     Enc2_old = Enc2_new;
-    //Serial.println("Encoder 2: ");
-    //Serial.println(Enc2_new);
     usbMIDI.sendControlChange(cc_length, Enc2_new, midi_chan_inst2);
     digitalWrite(Pin_MIDIled, HIGH);
   }
@@ -327,8 +310,6 @@
   //send MIDI Encoder 4 [Duration Instrument 2]
   if (Enc4_new != Enc4_old) {
     Enc4_old = Enc4_new;
-    //Serial.println("Encoder 4: ");
-    //Serial.println(Enc4_new);
     usbMIDI.sendControlChange(cc_duration, Enc4_new, midi_chan_inst2);
     digitalWrite(Pin_MIDIled, HIGH);
   }
--- a/CollidoscopeTeensy/CollidoscopeTeensy_original.ino	Tue Jul 19 11:43:37 2016 +0200
+++ b/CollidoscopeTeensy/CollidoscopeTeensy_original.ino	Fri Jul 22 14:30:58 2016 +0200
@@ -80,9 +80,6 @@
 const int Pin_record2_led =  5; //D5
 const int Pin_MIDIled =  6;
 
-//const int Pin_reset1 = 22;    //B2, not in use
-//const int Pin_reset2 = 25;    //B5, not in use
-
 Bounce button1 = Bounce(Pin_play1, 5); 
 Bounce button2 = Bounce(Pin_record1, 5); 
 Bounce button3 = Bounce(Pin_play2, 5); 
@@ -95,7 +92,7 @@
 
 
 // Variables
-const int jitter_thresh = 10; //7threshold value for analog INs to suppress sending MIDI due to input jitter 
+const int jitter_thresh = 10; // threshold value for analog INs to suppress sending MIDI due to input jitter 
 
 void setup() {  
 
@@ -140,10 +137,10 @@
   button4.update();
 
   
-  uint16_t Jet1_new = analogRead(0); //read Wavejet/Rail 1
-  uint16_t Jet2_new = analogRead(1); //read Wavejet/Rail 2
-  uint16_t filter1_new = analogRead(2);   //read filter Instrument 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
-  uint16_t filter2_new = analogRead(4);   //read filter Instrument 2; ADJUST INPUT RANGE ACCORDING TO SENSOR  
+  uint16_t Jet1_new = analogRead(0);      //read Wavejet/Rail 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
+  uint16_t Jet2_new = analogRead(1);      //read Wavejet/Rail 2; ADJUST INPUT RANGE ACCORDING TO SENSOR    
+  uint16_t filter1_new = analogRead(2);   //read filter Instrument 1;    
+  uint16_t filter2_new = analogRead(4);   //read filter Instrument 2;
   uint16_t dur1_new = analogRead(3); 
   uint16_t dur2_new = analogRead(5);
 
@@ -191,9 +188,8 @@
  }
 
  //send MIDI Wavejet 1 [Position Instrument 1]
-   //Serial.print("W1>"); Serial.println(Jet1_new);
+ //<calibrate>
  if (Jet1_new > Jet1_old+jitter_thresh || Jet1_new < Jet1_old-jitter_thresh) {
-    //int16_t midiVal = constrain( map(Jet1_new, 24, 926, 0, 149), 0, 149 );
     int16_t midiVal = constrain( map(Jet1_new, 18, 800, 0, 149), 0, 149 );
     if( midiVal != Jet1_old_MIDI ){
       Jet1_old_MIDI = midiVal;
@@ -207,7 +203,6 @@
 
  //send MIDI Filter 1 [Filter Instrument 1]
  if ( filter1_new != filter1_old ) {
-
     int16_t midiVal = constrain( map(filter1_new, 0, 1024, 0, 127), 0, 127 );
     if( midiVal != filter1_old_MIDI){
       //Serial.println( midiVal );
@@ -223,7 +218,6 @@
  
     int16_t midiVal = constrain( map(dur1_new, 0, 1024, 0, 127), 0, 127 );
     if( midiVal != dur1_old_MIDI){
-      //Serial.println( midiVal );
       dur1_old_MIDI = midiVal;
       usbMIDI.sendControlChange(cc_duration, midiVal, midi_chan_inst1);
     }
@@ -235,8 +229,6 @@
   //send MIDI Encoder 1 [Selection length Instrument 1]
   if (Enc1_new != Enc1_old) {
     Enc1_old = Enc1_new;
-    //Serial.println("Encoder 1: ");
-    //Serial.println(Enc1_new);
     usbMIDI.sendControlChange(cc_length, Enc1_new, midi_chan_inst1);
     digitalWrite(Pin_MIDIled, HIGH);
   }
@@ -261,9 +253,8 @@
   }
 
   //send MIDI Wavejet 2 [Position Instrument 2]
-  // Serial.print("W2>"); Serial.println(Jet2_new);
+  //<calibrate>
   if (Jet2_new > Jet2_old+jitter_thresh || Jet2_new < Jet2_old-jitter_thresh) {
-    //int16_t midiVal = constrain( map( Jet2_new, 925, 18, 149, 0 ), 0, 149 );
     int16_t midiVal = constrain( map( Jet2_new, 15, 780, 0, 149 ), 0, 149 );
     if( midiVal != Jet2_old_MIDI ){
       Jet2_old_MIDI = midiVal;