Revision 11:76344930dd84

View differences:

CollidoscopeTeensy/CollidoscopeTeensy_new.ino
67 67
//Default Values:
68 68
const int  Enc_def = 64; //default selection length  
69 69
int MIDI_led_state = LOW;
70
//boolean reset1 = true;
71
//boolean reset2 = true;
72 70

  
73 71
///////////////////////////////////////////////////
74 72
// Interface Inputs
......
141 139
  button4.update();
142 140

  
143 141
  
144
  uint16_t Jet1_new = analogRead(0); //read Wavejet/Rail 1
145
  uint16_t Jet2_new = analogRead(1); //read Wavejet/Rail 2
142
  uint16_t Jet1_new = analogRead(0);      //read Wavejet/Rail 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
143
  uint16_t Jet2_new = analogRead(1);      //read Wavejet/Rail 2; ADJUST INPUT RANGE ACCORDING TO SENSOR    
146 144
  uint16_t filter1_new = analogRead(2);   //read filter Instrument 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
147 145
  uint16_t filter2_new = analogRead(4);   //read filter Instrument 2; ADJUST INPUT RANGE ACCORDING TO SENSOR  
148 146

  
......
199 197
 
200 198
 //Instrument 1 Controls//////////////////////////////////////  
201 199
 
202
 //Loop/Keymode Switch Instrument 1 
203
   
200
 //Loop/Keymode Switch Instrument 1    
204 201
 if (button1.risingEdge()) {   
205
   //Serial.println("Loop mode");
206 202
   usbMIDI.sendControlChange(cc_play, 1, midi_chan_inst1);
207 203
 }
208 204
   
209 205
 if (button1.fallingEdge()) {   
210
   //Serial.println("Keyboardmode mode");
211 206
   usbMIDI.sendControlChange(cc_play, 0, midi_chan_inst1);
212 207
 }
213 208
     
214 209
   
215 210
 //Record Instrument 1
216 211
 if (button2.fallingEdge()) {   
217
   //Serial.println("RECORD! Instrument 1");
218 212
   usbMIDI.sendControlChange(cc_record, 1, midi_chan_inst1);
219 213
 }
220 214

  
221 215
 //send MIDI Wavejet 1 [Position Instrument 1]
216
 //<calibrate>
222 217
 if (Jet1_new > Jet1_old+jitter_thresh || Jet1_new < Jet1_old-jitter_thresh) {
223 218
    
224 219
    int16_t midiVal = constrain( map(Jet1_new, 988, 121, 0, 149), 0, 149 );
225
    // int16_t midiVal = constrain( map( Jet1_new, 23, 928, 0, 149 ), 0, 149 ); old collidoscope 
226 220
    if( midiVal != Jet1_old_MIDI ){
227 221
      Jet1_old_MIDI = midiVal;
228 222
      usbMIDI.sendPitchBend( midiVal, midi_chan_inst1 );
......
234 228

  
235 229

  
236 230
 //send MIDI Filter 1 [Filter Instrument 1]
237

  
238
 if ( filter1_new > filter1_old+jitter_thresh_short || filter1_new < filter1_old-jitter_thresh_short ) {         // maybe adding jitter threshold needed, see Jet1_new  
231
 //<calibrate>
232
 if ( filter1_new > filter1_old+jitter_thresh_short || filter1_new < filter1_old-jitter_thresh_short ) {
239 233
 
240 234
    int16_t midiVal = constrain( map(filter1_new, 145, 756, 0, 127), 0, 127 );
241 235
    if( midiVal != filter1_old_MIDI){
......
251 245
  //send MIDI Encoder 1 [Selection length Instrument 1]
252 246
  if (Enc1_new != Enc1_old) {
253 247
    Enc1_old = Enc1_new;
254
    //Serial.println("Encoder 1: ");
255
    //Serial.println(Enc1_new);
256 248
    usbMIDI.sendControlChange(cc_length, Enc1_new, midi_chan_inst1);
257 249
    digitalWrite(Pin_MIDIled, HIGH);
258 250
  }
......
260 252
  //send MIDI Encoder 3 [Duration Instrument 1]
261 253
  if (Enc3_new != Enc3_old) {
262 254
    Enc3_old = Enc3_new;
263
    //Serial.println("Encoder 3: ");
264
    //Serial.println(Enc3_new);
265 255
    usbMIDI.sendControlChange(cc_duration, Enc3_new, midi_chan_inst1);
266 256
    digitalWrite(Pin_MIDIled, HIGH);
267 257
  }
......
270 260
  //Instrument 2 Controls//////////////////////////////////////  
271 261
  
272 262
  //Loop/Keymode Switch Instrument 2
273
   
274 263
  if (button3.risingEdge()) {   
275
    //Serial.println("Loop mode");
276 264
    usbMIDI.sendControlChange(cc_play, 1, midi_chan_inst2);
277 265
  }
278 266
  
279 267
  if (button3.fallingEdge()) {   
280
    //Serial.println("Keyboardmode mode");
281 268
    usbMIDI.sendControlChange(cc_play, 0, midi_chan_inst2);
282 269
  }
283 270
  
284 271
  //Record Instrument 2
285 272
  if (button4.fallingEdge()) {   
286
    //Serial.println("RECORD! Instrument 2");
287 273
    usbMIDI.sendControlChange(cc_record, 1, midi_chan_inst2);
288 274
  }
289 275

  
290 276
  //send MIDI Wavejet 2 [Position Instrument 2]
291
  
277
  // <calibrate>
292 278
  if (Jet2_new > Jet2_old+jitter_thresh || Jet2_new < Jet2_old-jitter_thresh) {
293
    //Serial.println("RECORD! Instrument 2");
294 279
    int16_t midiVal = constrain( map( Jet2_new, 109, 992, 149, 0 ), 0, 149 );
295 280
    if( midiVal != Jet2_old_MIDI ){
296 281
      Jet2_old_MIDI = midiVal;
......
301 286
    digitalWrite(Pin_MIDIled, HIGH);
302 287
  }
303 288
  
304
 //Serial.println(filter2_new);
305
   if ( filter2_new > filter2_old+jitter_thresh_short || filter2_new < filter2_old-jitter_thresh_short ) {         // maybe adding jitter threshold needed, see Jet1_new  
289
  //send MIDI Filter 2 [Filter Instrument 2]
290
  //<calibrate>
291
  if ( filter2_new > filter2_old+jitter_thresh_short || filter2_new < filter2_old-jitter_thresh_short ) {
306 292
    int16_t midiVal = constrain( map(filter2_new, 132, 700, 0, 127), 0, 127 );
307 293
    if( midiVal != filter2_old_MIDI){
308
      //Serial.println( midiVal );
309 294
      filter2_old_MIDI = midiVal;
310 295
      usbMIDI.sendControlChange(cc_filter, midiVal, midi_chan_inst2);
311 296
    }
......
318 303
  //send MIDI Encoder 2 [Selection length Instrument 2]
319 304
  if (Enc2_new != Enc2_old) {
320 305
    Enc2_old = Enc2_new;
321
    //Serial.println("Encoder 2: ");
322
    //Serial.println(Enc2_new);
323 306
    usbMIDI.sendControlChange(cc_length, Enc2_new, midi_chan_inst2);
324 307
    digitalWrite(Pin_MIDIled, HIGH);
325 308
  }
......
327 310
  //send MIDI Encoder 4 [Duration Instrument 2]
328 311
  if (Enc4_new != Enc4_old) {
329 312
    Enc4_old = Enc4_new;
330
    //Serial.println("Encoder 4: ");
331
    //Serial.println(Enc4_new);
332 313
    usbMIDI.sendControlChange(cc_duration, Enc4_new, midi_chan_inst2);
333 314
    digitalWrite(Pin_MIDIled, HIGH);
334 315
  }
CollidoscopeTeensy/CollidoscopeTeensy_original.ino
80 80
const int Pin_record2_led =  5; //D5
81 81
const int Pin_MIDIled =  6;
82 82

  
83
//const int Pin_reset1 = 22;    //B2, not in use
84
//const int Pin_reset2 = 25;    //B5, not in use
85

  
86 83
Bounce button1 = Bounce(Pin_play1, 5); 
87 84
Bounce button2 = Bounce(Pin_record1, 5); 
88 85
Bounce button3 = Bounce(Pin_play2, 5); 
......
95 92

  
96 93

  
97 94
// Variables
98
const int jitter_thresh = 10; //7threshold value for analog INs to suppress sending MIDI due to input jitter 
95
const int jitter_thresh = 10; // threshold value for analog INs to suppress sending MIDI due to input jitter 
99 96

  
100 97
void setup() {  
101 98

  
......
140 137
  button4.update();
141 138

  
142 139
  
143
  uint16_t Jet1_new = analogRead(0); //read Wavejet/Rail 1
144
  uint16_t Jet2_new = analogRead(1); //read Wavejet/Rail 2
145
  uint16_t filter1_new = analogRead(2);   //read filter Instrument 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
146
  uint16_t filter2_new = analogRead(4);   //read filter Instrument 2; ADJUST INPUT RANGE ACCORDING TO SENSOR  
140
  uint16_t Jet1_new = analogRead(0);      //read Wavejet/Rail 1; ADJUST INPUT RANGE ACCORDING TO SENSOR    
141
  uint16_t Jet2_new = analogRead(1);      //read Wavejet/Rail 2; ADJUST INPUT RANGE ACCORDING TO SENSOR    
142
  uint16_t filter1_new = analogRead(2);   //read filter Instrument 1;    
143
  uint16_t filter2_new = analogRead(4);   //read filter Instrument 2;
147 144
  uint16_t dur1_new = analogRead(3); 
148 145
  uint16_t dur2_new = analogRead(5);
149 146

  
......
191 188
 }
192 189

  
193 190
 //send MIDI Wavejet 1 [Position Instrument 1]
194
   //Serial.print("W1>"); Serial.println(Jet1_new);
191
 //<calibrate>
195 192
 if (Jet1_new > Jet1_old+jitter_thresh || Jet1_new < Jet1_old-jitter_thresh) {
196
    //int16_t midiVal = constrain( map(Jet1_new, 24, 926, 0, 149), 0, 149 );
197 193
    int16_t midiVal = constrain( map(Jet1_new, 18, 800, 0, 149), 0, 149 );
198 194
    if( midiVal != Jet1_old_MIDI ){
199 195
      Jet1_old_MIDI = midiVal;
......
207 203

  
208 204
 //send MIDI Filter 1 [Filter Instrument 1]
209 205
 if ( filter1_new != filter1_old ) {
210

  
211 206
    int16_t midiVal = constrain( map(filter1_new, 0, 1024, 0, 127), 0, 127 );
212 207
    if( midiVal != filter1_old_MIDI){
213 208
      //Serial.println( midiVal );
......
223 218
 
224 219
    int16_t midiVal = constrain( map(dur1_new, 0, 1024, 0, 127), 0, 127 );
225 220
    if( midiVal != dur1_old_MIDI){
226
      //Serial.println( midiVal );
227 221
      dur1_old_MIDI = midiVal;
228 222
      usbMIDI.sendControlChange(cc_duration, midiVal, midi_chan_inst1);
229 223
    }
......
235 229
  //send MIDI Encoder 1 [Selection length Instrument 1]
236 230
  if (Enc1_new != Enc1_old) {
237 231
    Enc1_old = Enc1_new;
238
    //Serial.println("Encoder 1: ");
239
    //Serial.println(Enc1_new);
240 232
    usbMIDI.sendControlChange(cc_length, Enc1_new, midi_chan_inst1);
241 233
    digitalWrite(Pin_MIDIled, HIGH);
242 234
  }
......
261 253
  }
262 254

  
263 255
  //send MIDI Wavejet 2 [Position Instrument 2]
264
  // Serial.print("W2>"); Serial.println(Jet2_new);
256
  //<calibrate>
265 257
  if (Jet2_new > Jet2_old+jitter_thresh || Jet2_new < Jet2_old-jitter_thresh) {
266
    //int16_t midiVal = constrain( map( Jet2_new, 925, 18, 149, 0 ), 0, 149 );
267 258
    int16_t midiVal = constrain( map( Jet2_new, 15, 780, 0, 149 ), 0, 149 );
268 259
    if( midiVal != Jet2_old_MIDI ){
269 260
      Jet2_old_MIDI = midiVal;

Also available in: Unified diff