Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy 4.0 MIDIx16 with Stretch Sensor

  1. #1
    Junior Member
    Join Date
    May 2022
    Posts
    2

    Teensy 4.0 MIDIx16 with Stretch Sensor

    Hi,

    I am totally new with Teensy (have a very basic understanding of the code) and am trying to build a MIDI controller with 16 stretch sensors (adafruit conductive rubber) as separate MIDI inputs. ultimately, I would like to map each stretch sensor to a different parameter in Ableton Live.

    I got the code/wiring/connection with Ableton working for one sensor:

    Code:
    #include <MIDI.h>
    int Stretch1 = 0; //name of data from sensor
    
    void setup() { }
    void loop() {
    
      {  int accum = 0; // define a place to add values
      for (int i = 0; i < 10; i++){ // loop ten times
        accum += analogRead(14); // add the reading to accum
      }
    
      int value = accum/10; // get average
    
    Serial.print("amazing "); //so it says which string
    Serial.println(value); // print to serial monitor
    
      Stretch1 = constrain(analogRead(14), 103, 211); //min max analogread
      Stretch1 = map(Stretch1, 103, 211, 0, 127); //mapping the analogread
      int valueStretch1 = Stretch1;
      usbMIDI.sendControlChange(1,valueStretch1, 1); //(midi number, value, ?)
    
        while (usbMIDI.read()) {} //needed for no bugs
      delay(10);
    
    }
    }
    but I am stuck in extending it to more than one sensor.

    for some reason I cannot upload a picture of my wiring, but as I said it works for one sensor, so I would just repeat the same circuit for another analgueRead and use usbMIDI.sendControlChange(1,valueStretch1, 1) to specify the channel? next to the code, I am not entirely sure about how to use the Teensy as a MIDIx16 in Ableton.

    I am working with Mac (Monterey), Arduino 1.8.19 incl Teensyduino 1.56.

    if anything is unclear, please let me know, very new to this

    I really appreciate all suggestions/help!!

    cheers,
    franziska

  2. #2
    Junior Member
    Join Date
    May 2022
    Posts
    2
    figured the code out, in case this helps someone in the future.

    Code:
    #include <MIDI.h>
    int Stretch1 = 0; //name of data from sensor
    int Stretch2 = 1;
    
    void setup() { }
    void loop() {
    
      { int accum1 = 0;
      for (int i = 0; i < 10; i++){
        accum1 += analogRead(14);
      }
      
      int value = accum1/10;
      
    //  Serial.print("Stretch1 "); //so it says which string
    //  Serial.println(value); // print to serial monitor
    
      Stretch1 = constrain(analogRead(14), 320, 600); //min max analogread
      Stretch1 = map(Stretch1, 320, 600, 0, 127); //mapping the analogread
      int valueStretch1 = Stretch1;
      usbMIDI.sendControlChange(1,valueStretch1, 1); //(midi number, value, ?)
      }
    
      { int accum2 = 0;
       for (int i = 0; i < 10; i++){
        accum2 += analogRead(15);
      }
      
      int value2 = accum2/10;
    
    //  Serial.print("Stretch2 ");
    //  Serial.println(value2);
    
      Stretch2 = constrain(analogRead(15), 380, 740); //min max analogread
      Stretch2 = map(Stretch2, 380, 740, 0, 127); //mapping the analogread
      int valueStretch2 = Stretch2;
      usbMIDI.sendControlChange(2,valueStretch2, 2); //(midi number, value, ?)
    
      while (usbMIDI.read()) {} //needed for no bugs
      delay(10);
    
    }
    }

    but I still don't know how to let Ableton know which sensor to pick up when i map a MIDI control. it automatically takes the last (so in this case CC2). if someone knows, I'd be curious as for now I am working with a slightly annoying workaround.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •