Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCRotaryEncoder outputing only two values #95

Open
laual opened this issue Jan 23, 2020 · 3 comments
Open

CCRotaryEncoder outputing only two values #95

laual opened this issue Jan 23, 2020 · 3 comments

Comments

@laual
Copy link

laual commented Jan 23, 2020

Hi,

I'm trying to connect a rotary encoder to my Teensy 3.6 with the CCRotaryEncoder class but all I'm getting as output are two values like the DigitalCCSender.

#include <Encoder.h>
#include <Control_Surface.h>

USBMIDI_Interface midi;

const int speedMultiplier = 1;

CCRotaryEncoder enc1 = {
  {0,1},                                // pins
  {MIDI_CC::Pan, CHANNEL_1},
  speedMultiplier,                       // multiplier
  4,
};

void setup() {
  Control_Surface.begin();
}

void loop() { Control_Surface.loop(); }

Could anyone help with this problem?

Thanks!

@tttapa
Copy link
Owner

tttapa commented Jan 23, 2020

This is the expected behavior. Rotary encoders send relative MIDI messages (1 = +1, 127 = -1). You can most likely configure relative mode in your DAW or other MIDI software.
There are three main relative MIDI modes, you can set the correct mode for your software using RelativeCCSender::setMode(...) (example).
If your software doesn't support relative mode, you can use the CCAbsoluteEncoder class.

@laual
Copy link
Author

laual commented Jan 23, 2020

Thanks, I would like to control hardware synths though. CCAbsoluteEncoder works already better but implies that I can't go below the initial value. If I'm correct I would need to query the value from my synth and increment it with the CCRoteryEncoder? Or is there a better way?

@tttapa
Copy link
Owner

tttapa commented Jan 23, 2020

I can't go below the initial value

Not sure what you mean, CCAbsoluteEncoder should go all the way from 0 up to 127, which is the full MIDI CC range.

If I'm correct I would need to query the value from my synth and increment it with the CCRoteryEncoder? Or is there a better way?

There's an unmerged feature branch https://github.com/tttapa/Control-Surface/tree/share-encoder that has a set method for the CCAbsoluteEncoder class. You can then query the synth, and set the value of the encoder using this method:

void set(uint16_t value) {
zeroOffsetPosition =
encoder.read() - (long)value * pulsesPerStep / multiplier;
}

You have to use my fork of the Encoder library in order to use the code on that branch:
https://github.com/tttapa/Encoder
(Keep in mind that you also have to remove the Encoder library that comes preinstalled with Teensyduino for this to work on a Teensy. On my installation, it's located in arduino-1.8.9/hardware/teensy/avr/libraries/Encoder.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants