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

rotary encoders #13

Closed
masydoblig opened this issue Feb 14, 2019 · 21 comments
Closed

rotary encoders #13

masydoblig opened this issue Feb 14, 2019 · 21 comments

Comments

@masydoblig
Copy link

Hi Peter

How you going

So i have updated my library to your latest version of control surface
and just going through and changing all the namespaces
but i cant find any examples of the rotary encoder code lines

can you help me out or point me in the right direction where i can find it

i was using the old RotaryEncoder for my pan control and now it throws an error on compiling
says it does not name a type

sorry to bother you with something so trivial (i really am terrible at any form of coding)

and thanks again you have put a lot of time and effort into this code and i really appreciate it

@tttapa
Copy link
Owner

tttapa commented Feb 14, 2019

Hi,
The RotaryEncoder class has been renamed to CCRotaryEncoder.
The interface has been changed as well, you can find the documentation for it here:
https://tttapa.github.io/Control-Surface/Doc/Doxygen/d3/d62/classCCRotaryEncoder.html

My apologies for the lack of proper examples or better documentation, the library has gotten really huge, and I have to find ways to combine working on it with my studies.

@masydoblig
Copy link
Author

masydoblig commented Feb 14, 2019 via email

@tttapa
Copy link
Owner

tttapa commented Feb 14, 2019

I'm in Belgium, it's 11:11 am here, no worries :)

@masydoblig
Copy link
Author

i have tried everything to get the rotary encoder working with no luck

either i have the incorrect encoder.H library or i am writing the code incorrect to create a new instance of CCRotaryEncoder

any help with an example would be greatly appreciated

also in the MCU protocol what midi message is it sending out for the VU meters

image

im hoping i can just send the midi data from cubase (which i can set the type of midi message on) to the controller and get the vu on a shift register working

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

I added a rotary encoder example: https://tttapa.github.io/Control-Surface/Doc/Doxygen/d3/d15/CCRotaryEncoder_8ino-example.html

also in the MCU protocol what midi message is it sending out for the VU meters

It uses MIDI Channel Pressure events: the high nibble of the data byte is the track (0-7) and the low nibble is the value (0x0-0xC) or clear overload (0xF) or set overload (0xE). 0xD has no meaning.

@masydoblig
Copy link
Author

ok looking at the code you have put up it i would have to use the mcu mapping
is there any way for me to set specific channels and addresses like we could before?
so i can use the generic mapping in cubase

RotaryEncoder encoder(2, 3, 0x14, 1, speedMultiply, NORMAL_ENCODER, TWOS_COMPLEMENT);// comes through as a controller on channel 1,address 20

or has this all changed?

i.e.

CCRotaryEncoder enc ={
{2, 3},
MIDI_CC::Pan, CHANNEL_1,
1,
4,
};

The Reason for me to do this is i can do alot more through the generic program function in cubase
even create banks and flip modes

@masydoblig
Copy link
Author

this code below works

CCRotaryEncoder enc ={
{2, 3},
MIDI_CC::Pan,
1,
4,
};

it functions well and comes though to cubase on Channel 1 address 10

but i cant change channel number

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

You have to add curly braces, the address is a single parameter:

CCRotaryEncoder enc ={
  {2, 3},
  {MIDI_CC::Pan, CHANNEL_1},
  1,
  4,
};

https://tttapa.github.io/Control-Surface/Doc/Doxygen/d3/d10/classMIDICNChannelAddress.html#a20a349458b4401d584e9ee713be0a8dc

@masydoblig
Copy link
Author

Using the generic controller function is also why i was asking about the vu meters

when i set it to a Mackie controller in cubase my Vu meter works
but i cant set a specific channel and address in the code to use with the generic controller

@masydoblig
Copy link
Author

image

@masydoblig
Copy link
Author

Ok that makes sense
it compiles now

you are an awesome dude

How did you go with finding some Arduino Nano Boards to test out your faders????

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

when i set it to a Mackie controller in cubase my Vu meter works
but i cant set a specific channel and address in the code to use with the generic controller

Could you check what kinds of messages Cubase sends? The easiest way is to use a MIDI monitor on you computer, alternatively, enable debugging information in Settings.hpp: uncomment lines 17 and 19.

How did you go with finding some Arduino Nano Boards to test out your faders????

I started working on it, but I don't have the right hardware here right now.

@masydoblig
Copy link
Author

Can you suggest a MIDI monitor to try

i have midi ox installed but it wont get anything from cubase

Feel free to Face time me on masydoblig@hotmail.com so you can see it all

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

I use MIDI Snoop on Linux, but any monitor that runs on your platform should work.

Edit: it seems that the MIDISnoop domain has expired, and is now just spam. It's still in the repositories though: https://packages.ubuntu.com/bionic/sound/midisnoop

@masydoblig
Copy link
Author

hmmmmm i tried the debug but it wouldnt compile and just had errors

and for some reason the midi monitor wont connect when cubase is running

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

Did you pull the latest version of the library?

@masydoblig
Copy link
Author

yep yesterday

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

I pushed another change this morning, that should have fixed the debug issues.

Did you install the library using git? https://tttapa.github.io/Control-Surface/Doc/Doxygen/d4/d6d/md_Installation.html
In that case, you can just do git pull to update to the latest version.

@masydoblig
Copy link
Author

i have just downloaded the new version
it compiles
and i have put the USBDebugMIDI_Interface into the code but it doesnt seem to do anything
still works as a controller though

i might have to give up for the night,
have good day pete

Here is what i have so far

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

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

USBDebugMIDI_Interface midiInterface(115200);

const pin_t dataPin = 12; // Pin connected to DS of 74HC595
const pin_t clockPin = 13; // Pin connected to SH_CP of 74HC595
const pin_t latchPin = 10; // Pin connected to ST_CP of 74HC595

// Create a new shift register output connected to pins 12, 13 and 10,
// shift the data out with the most significant bit first.
// There are 8 outputs in total.
ShiftRegisterOut<12> sr(dataPin, clockPin, latchPin, MSBFIRST);

Channel channel = CHANNEL_1;
// Note: a VU meter of 12 LEDs will give the best effect, because
// in the MCU protocol, there are 12 values
MCU::VULEDs<12> vu = {
{0x01, channel},
{{
sr.pin(0),
sr.pin(1),
sr.pin(2),
sr.pin(3),
sr.pin(4),
sr.pin(5),
sr.pin(6),
sr.pin(7),
sr.pin(8),
sr.pin(9),
sr.pin(10),
sr.pin(11),
}},
150, // decay time in milliseconds or MCU::VU::NO_DECAY
};

// Create a new instance of the class CCPotentiometer, called potentiometer,
// on pin A0, that sends MIDI messages with controller 7 (channel volume)
// on channel 1.
CCPotentiometer potentiometer(A0, {MIDI_CC::Channel_Volume, CHANNEL_1});

CCRotaryEncoder enc = {
{2, 3},
{MIDI_CC::Pan, CHANNEL_1},
1,
4,
};

using namespace MIDI_Notes;

// Instantiate the momentary push buttons that send out MIDI Note events.
NoteButton buttons[] = {
{22, {note(C, -1), CHANNEL_1}},
{23, {note(Db, -1), CHANNEL_1}},
{24, {note(D, -1), CHANNEL_1}},
{25, {note(Eb, -1), CHANNEL_1}},
{26, {note(E, -1), CHANNEL_1}},
{27, {note(F, -1), CHANNEL_1}},
{28, {note(Gb, -1), CHANNEL_1}},
{29, {note(G, -1), CHANNEL_1}},
{30, {note(Ab, -1), CHANNEL_1}},
{31, {note(A, -1), CHANNEL_1}},
{32, {note(Bb, -1), CHANNEL_1}},
{33, {note(B, -1), CHANNEL_1}},
{34, {note(C, 0), CHANNEL_1}},
{35, {note(Db, 0), CHANNEL_1}},
{36, {note(D, 0), CHANNEL_1}},
// If you want to set the channel specifically, you can use:
// {2, {note(C, 4), CHANNEL_1}},
};

MIDINoteLED leds[] = {
{40, {note(E, 2), CHANNEL_1}},
{41, {note(F, 2), CHANNEL_1}},
{42, {note(Gb, 2), CHANNEL_1}},
{43, {note(G, 2), CHANNEL_1}},
{44, {note(Ab, 2), CHANNEL_1}},
{45, {note(A, 2), CHANNEL_1}},
{46, {note(Bb, 2), CHANNEL_1}},
{47, {note(B, 2), CHANNEL_1}},
{48, {note(C, 3), CHANNEL_1}},
{49, {note(Db, 3), CHANNEL_1}},
{50, {note(D, 3), CHANNEL_1}},
{51, {note(Eb, 3), CHANNEL_1}},
{52, {note(E, 3), CHANNEL_1}},
{53, {note(F, 3), CHANNEL_1}},
};

void setup() {
// Initialize everything
Control_Surface.begin();
}

void loop() {
// Update the Control Surface (check whether the potentiometer's
// input has changed since last time, if so, send the new value over MIDI).
Control_Surface.loop();
}

@tttapa
Copy link
Owner

tttapa commented Feb 16, 2019

Keep the USBMIDI_Interface, don't use the debug interface, just enable debugging in Settings.hpp, see the link in a previous reply: #13 (comment)

Then open the Serial monitor and check the incoming messages (prefixed with >>>).

@masydoblig
Copy link
Author

all good close this issue if you want as the encoder is working well
i will start a new one for debugging

@tttapa tttapa closed this as completed Feb 17, 2019
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