Open brosekerg opened 3 years ago
This is not something MIDI_controller supports. Using Control Surface, you could do something like this:
#include <Control_Surface.h>
USBMIDI_Interface midi;
// Transpose settings [0, +1, +2, +3], with offsets of 16 semitones between them
Transposer<0, +3> transposer {16};
// Select the transposition using a potentiometer on pin A0
PotSelector<4> selector {transposer, A0};
Bankable::NoteButton buttons[] {
{transposer, 2, 45}, // transposer, pin, note number
{transposer, 3, 46}, // transposer, pin, note number
{transposer, 4, 47}, // transposer, pin, note number
// ...
};
void setup() {
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
The PotSelector
class is not included with Control Surface, but you could use something like this:
#include <Control_Surface.h>
template <setting_t N>
class PotSelector : public GenericSelector<N> {
public:
PotSelector(Selectable<N> &selectable, pin_t analogPin)
: GenericSelector<N>(selectable, {}), analogInput(analogPin) {}
void begin() override {
analogInput.resetToCurrentValue();
this->set(getPosition());
}
void update() override {
if (analogInput.update()) {
setting_t pos = getPosition();
if (pos != this->get())
this->set(pos);
}
}
private:
setting_t getPosition() const {
return N * analogInput.getValue() / (1 << Precision);
}
private:
constexpr static const uint8_t Precision = 7;
FilteredAnalog<Precision> analogInput;
};
If the buttons are connected through multiplexers, you could do something like this:
CD74HC4051 mux1 {6, {4, 3, 2}}; // input pin, {address pins}
CD74HC4051 mux2 {7, {4, 3, 2}}; // input pin, {address pins}
Bankable::NoteButton buttons[] {
{transposer, mux1.pin(0), 45}, // transposer, pin, note number
{transposer, mux1.pin(1), 46},
// ...
{transposer, mux1.pin(7), 52},
{transposer, mux2.pin(0), 53},
// ...
{transposer, mux2.pin(7), 61},
};
To use an encoder later, you can use the EncoderSelector
class instead of the PotSelector
. Also see this example: https://tttapa.github.io/Control-Surface-doc/Doxygen/d1/da6/Encoder-Selector-Bank_8ino-example.html
Use the CCPotentiometer
class for the regular FX pots. See this example: https://tttapa.github.io/Control-Surface-doc/Doxygen/d3/d8d/Multiple-Control-Change-Potentiometers_8ino-example.html
The MIDI bank select function selects banks of patches and instrument voices for synthesizers etc., it's not related to banks in the context of MIDI controllers.
does this look like correct control-surface code for having 16 buttons with my 4 octave semitone banks, and 4 CC potientiometers? im waiting on my 16x1 mux to test. but does this look like it will work?
USBMIDI_Interface midi;
using namespace MIDI_Notes;
CD74HC4067 mux1 = { 6, {2, 3, 4, 5} };
Transposer<-12, +12> transposer; IncrementDecrementSelector<transposer.getNumberOfBanks()> selector = { transposer, {7, 8}, Wrap::Clamp, };
Bankable::NoteButton buttons[] { {transposer, mux1.pin(8), {note(C, 3), CHANNEL_1}}, {transposer, mux1.pin(7), {note(Db, 3), CHANNEL_1}}, {transposer, mux1.pin(6), {note(D, 3), CHANNEL_1}}, {transposer, mux1.pin(5), {note(Eb, 3), CHANNEL_1}}, {transposer, mux1.pin(4), {note(E, 3), CHANNEL_1}}, {transposer, mux1.pin(3), {note(F, 3), CHANNEL_1}}, {transposer, mux1.pin(2), {note(Gb, 3), CHANNEL_1}}, {transposer, mux1.pin(1), {note(G, 3), CHANNEL_1}}, {transposer, mux1.pin(22), {note(Ab, 3), CHANNEL_1}}, {transposer, mux1.pin(21), {note(A, 3), CHANNEL_1}}, {transposer, mux1.pin(20), {note(Bb, 3), CHANNEL_1}}, {transposer, mux1.pin(19), {note(B, 3), CHANNEL_1}}, {transposer, mux1.pin(18), {note(C, 4), CHANNEL_1}}, {transposer, mux1.pin(17), {note(Db, 4), CHANNEL_1}}, {transposer, mux1.pin(16), {note(D, 4), CHANNEL_1}}, {transposer, mux1.pin(15), {note(Eb, 4), CHANNEL_1}}, };
CCPotentiometer potentiometers[] = { {A0, 0x10}, {A1, 0x11}, {A2, 0x12}, {A3, 0x13}, };
void setup() { // put your setup code here, to run once: Control_Surface.begin(); mux1.begin(); mux1.pinMode(0, INPUT_PULLUP); }
void loop() { Control_Surface.loop(); }
I have a working code and midi device for 16 buttons and 5 potentiometers. I want to use one of these potentiometers to choose between 4 banks notes. The notes need to be programmed into each bank, probably an array. The first bank is the one i got working already obviously, the only one, and it holds note numbers 45-60(c3-c4). i want bank2 to be 61-76, 3 to be 77-92, and 4 to be 92-107. This first bank is in an array already. I have this accomplished on an arduino uno using 2 8x1 MUX and a 2x1 MUX to act as the 4th selection bit to cover all 16 buttons. MUX1 is arduino pin 6, MUX2 is arduino pin 7, and MUX1 select pins go to pins 2,3,4 on arduino. A goes to 4, B goes to 3, C goes to 2. 2x1 MUX select is pin 5 and output is pin 8.
Arduino Uno (0-13)(A0-A5)
Using ddiakopoulos/hiduino flashed firmware. arduino is now native usb. I can use arduino as ISP(seperate arduino as programmer) to still upload sketches.)
using Midi.h, controller.h, and (can use control_surface if forced to.)
Arduino 1.8.13
Windows 10 20h2 64 bit
(The variables defined after the pots are defined are my attempts to try to make these banks work, they werent in the original working code. Its to give you guys an idea of what im trying to do. Take particular note of the getKey() function. that function is supposed to select the right note to play based on which button i have pressed(the variable pressed), and which bank im in which is determined by the position of A5. I want to use a click rotary encoder but dont have one so this pot is for testing purposes for now. The function is also supposed to map pot values 1-255 to 0, 256-512 to 1, 513-768 to bank 2, and 769-1023 to bank 3. This is supposed to simulate the encoder, although im not sure its needed. Next, note where i actually send the NoteOn command in the updateMuxButtons() function. (case 0) i Have added the "+ getKey(i)" there in an attempt to play the correct note based on which bank im in determined by all the above. Finally, you can take note of the bankSelect() function at the bottom, which may be a better solution overall. Right now i have the program variable set to 0 but im not sure this is correct. Ideally it needs to store all 64 notes in an array and know which one to pick based on which bank im in and which button i press. Can anyone help me?
MidiOx as monitor
This is my capstone project for college and i appreciate all the help i can get! I hope this issue is understandable and solvable, im not seeing anywhere else of people using a pot as a bank selector. Short Summary of goal: 16 buttons, 4 banks (covers 64 of 88 keys) and 4 regular FX pots. Thanks guys!