Teensy 3.1 midi rotary encoder to DAW

Status
Not open for further replies.
Hi guys,

I'm just getting started with building a midi controller using a teensy 3.1, it will mainly use some rotary encoders. I love the built in MIDI and Encoder coding examples from teensy and teensyduino, but I need some help with applying code to translate the encoder turns inside a daw (logic pro x). Currently i'm just using one of the examples with a basic midi message, and all i get is large knob movement and no consistancy.

code:

Code:
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>

Encoder myEnc(0, 1);

void setup() {
  Serial.begin(31250);
  Serial.println("Basic Encoder Test:");
}

long oldPosition  = -999;

void loop() {
  long newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    Serial.println(newPosition);
    usbMIDI.sendControlChange(B0, newPosition, 1);
  }
}



If anybody could point me in the right direction I'd really appreciate it.



thanks,

Daniel
 
Hi guys,

I'm just getting started with building a midi controller using a teensy 3.1, it will mainly use some rotary encoders. I love the built in MIDI and Encoder coding examples from teensy and teensyduino, but I need some help with applying code to translate the encoder turns inside a daw (logic pro x). Currently i'm just using one of the examples with a basic midi message, and all i get is large knob movement and no consistancy.

code:

Code:
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>

Encoder myEnc(0, 1);

void setup() {
  Serial.begin(31250);
  Serial.println("Basic Encoder Test:");
}

long oldPosition  = -999;

void loop() {
  long newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    Serial.println(newPosition);
    usbMIDI.sendControlChange(B0, newPosition, 1);
  }
}



If anybody could point me in the right direction I'd really appreciate it.



thanks,

Daniel

Just at a glance, it looks like you're trying to send the newPosition variable straight out as a MIDI CC value. MIDI CC range is 0-127, so you would need to do something to keep the variable within that range.

I would have a separate variable 'ccvalue' and use basic if statements to clamp it's range.
 
Status
Not open for further replies.
Back
Top