Hi Pieter,
is it possible to change my pot MIDI Channel according to the bank #? In my code, I have 1 pot only to change the parameter values and it's working on the 3 buttons but when I change banks, the buttons reflect the back change (MIDI Channel) but not the pot. Is it possible?
Thanks.
Code:
#include <Control_Surface.h> // Include the Control Surface library
// Initialize USB MIDI interface
USBMIDI_Interface midi;
// Define CC numbers for the parameters
const uint8_t ccNumbers[] = {22, 23, 24}; // CC numbers
// Define two buttons for bank selection
Bank<4> bank(1);
//*** PARTIAL SELECT***
//Bankable::CCButton partial_Sel[] {
//{bank, 4, {25, CHANNEL_1}}, // Button to select Bank 1
//{bank, 5, {26, CHANNEL_1}}, // Button to select Bank 2
//};
// Instantiate a Bank selector to control which one of the four Banks is active.
IncrementDecrementSelector<4> selector {
bank, // Bank to manage
{5, 4}, // push button pins (increment, decrement)
Wrap::Wrap, // Wrap around
};
// Define three buttons to select CC functions (latched)
Bankable::CCButtonLatched<4> function_Sel[] = {
{{bank, BankType::CHANGE_CHANNEL}, 3, {ccNumbers[0], CHANNEL_1}}, // Button on pin 3 for CC 22
{{bank, BankType::CHANGE_CHANNEL}, 2, {ccNumbers[1], CHANNEL_1}}, // Button on pin 2 for CC 23
{{bank, BankType::CHANGE_CHANNEL}, 1, {ccNumbers[2], CHANNEL_1}} // Button on pin 1 for CC 24
};
// Potentiometer on pin A0
CCPotentiometer potentiometer = {A0, {ccNumbers[0], CHANNEL_1}}; // Default to the first CC number
// Function to update the potentiometer's CC number
void updatePotCC(uint8_t ccNumber) {
potentiometer.setAddress({ccNumber, CHANNEL_1}); // Update potentiometer CC using setAddress
}
void setup() {
// Initialize Control Surface
Control_Surface.begin();
}
void loop() {
// Check if any of the latched function buttons are pressed
for (int i = 0; i < 3; ++i) {
if (function_Sel[i].getButtonState() == Button::Falling) {
updatePotCC(ccNumbers[i]); // Update the potentiometer based on the selected button
}
}
// Process Control Surface (sends MIDI messages)
Control_Surface.loop();
}