Control-Surface
Control-Surface copied to clipboard
Using encoder to scroll tracks and change banks
Hi there:) First of all thank you a ton for this library and the energy to answer so many questions!!!!!
I am building a midi console to control ableton with. I want to have some banks so i can map my potentiometers to different settings depending on the bank selected. Also I want to be able to scroll through my tracks(this was solved by using remotify to generate a python script).
Is it possible to use my encoder in the following way:
When connected on the computer and ableton, due to the script installed, by rotating the encocder i scroll through my tracks. When the push button of the encoder is pressed, my encoder exits scrolling mode and enters bank mode, meaning when i rotate my encoder it scrolls through the different banks. When the push button of the encoder is pressed again the encoder goes back to scrolling through the tracks
I saw this issue https://github.com/tttapa/Control-Surface/issues/448 and I thought maybe with the help of borrowed encoder classes I could solve my issue. I haven't figured a way yet to modify the code below so I can change the banks as well... Any help appreciated:)
#include <Control_Surface.h
USBMIDI_Interface midi;
using namespace ExtIO;
using namespace MIDI_Notes;
//////////////////////////////////MULTIPLEXER/////////////////////////////////
//CREATE MUX
CD74HC4067 mux = {
4, // Common Digital pin
{5, 6, 7, 8} // Address pins S0, S1, S2, S3
};
//DECLARE MUXBUTTONS
const pin_t RotarySW = mux.pin(0);
Button EncoderClick = (RotarySW);
////////////////////////////////////////ENCODER//////////////////
// DECLARE PHYSICAL ENCODER
Encoder enc (2, 3);
//DECLARE VIRTUAL ENCODER FROM PHYSICAL
//enc - used as track selector
BorrowedCCRotaryEncoder TrackSelectenc = {
enc,
{MIDIAddress(20, CHANNEL_1)},
1,
};
//Volumeenc - used as Volume Control
BorrowedCCRotaryEncoder Volumeenc = {
enc,
{MIDIAddress(21, CHANNEL_1)},
1,
};
///////////////VARIABLES/////////
bool toggle = 1;
void setup()
{
Control_Surface.begin();
EncoderClick.begin();
RelativeCCSender::setMode(relativeCCmode::TWOS_COMPLEMENT);
BorrowedCCRotaryEncoder::disable(Volumeenc);
}
void loop() {
Control_Surface.loop();
//EncoderClick.invert();
if (EncoderClick.update()==Button::Falling){
toggle = !toggle;
if (toggle) {
BorrowedCCRotaryEncoder::enable(Volumeenc);
BorrowedCCRotaryEncoder::disable(TrackSelectenc);
} else {
BorrowedCCRotaryEncoder::enable(TrackSelectenc);
BorrowedCCRotaryEncoder::disable(Volumeenc);
}
digitalWrite (27, toggle); //LED FEEDBACK toggle state
};
};