Replies: 1 comment 1 reply
-
You'll need a bit of boilerplate. You can add this to a separate tab: MultiBankNoteButtonMatrix.hpp #pragma once
#include <Control_Surface.h>
template <uint8_t NumBanks, uint8_t NumRows, uint8_t NumCols>
class MultiBankMatrixAddress {
public:
MultiBankMatrixAddress(const Array<OutputBankableMIDIAddress, NumBanks> &banks,
const AddressMatrix<NumRows, NumCols> &addresses,
MIDIChannelCable channelCN)
: banks(banks), addresses(addresses), channelCN(channelCN) {}
void lock() {
for (auto &bank : banks)
bank.lock();
}
void unlock() {
for (auto &bank : banks)
bank.unlock();
}
uint8_t getBaseAddress(uint8_t row, uint8_t col) const {
return addresses[row][col];
}
MIDIAddress getActiveAddress(uint8_t row, uint8_t col) const {
MIDIAddress address {getBaseAddress(row, col), channelCN};
for (const auto &bank : banks)
address += bank.getAddressOffset();
return address;
}
private:
Array<OutputBankableMIDIAddress, NumBanks> banks;
AddressMatrix<NumRows, NumCols> addresses;
MIDIChannelCable channelCN;
};
template <uint8_t NumRows, uint8_t NumCols>
using MultiBankNoteButtonMatrixBase =
Bankable::MIDIButtonMatrix<MultiBankMatrixAddress<2, NumRows, NumCols>,
DigitalNoteSender, NumRows, NumCols>;
template <uint8_t NumRows, uint8_t NumCols>
class MultiBankNoteButtonMatrix : public MultiBankNoteButtonMatrixBase<NumRows, NumCols> {
public:
MultiBankNoteButtonMatrix(OutputBankConfig<> bank1,
OutputBankConfig<> bank2,
const PinList<NumRows> &rowPins,
const PinList<NumCols> &colPins,
const AddressMatrix<NumRows, NumCols> ¬es,
MIDIChannelCable channelCN = {CHANNEL_1, CABLE_1},
uint8_t velocity = 0x7F)
: MultiBankNoteButtonMatrixBase<NumRows, NumCols> {
{{bank1, bank2}, notes, channelCN},
rowPins,
colPins,
{velocity},
} {}
void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
uint8_t getVelocity() const { return this->sender.getVelocity(); }
}; Sketch.ino #include "MultiBankNoteButtonMatrix.hpp"
USBMIDI_Interface midi;
// Instantiate a Transposer that can transpose from one octave down to one
// octave up
Transposer<-3, +3> transposer(12);
// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector = {
transposer,
{1, 0},
Wrap::Clamp,
};
// Bank with 10 settings in total, increments of 1 address at a time
Bank<10> bank {1};
// A rotary encoder to select one of the 10 bank settings CHANNEL SELECTOR
EncoderSelector<10> selectorCH {
bank, // bank to manage
{11, 12}, // encoder pins
2, // encoder pulses per step
Wrap::Clamp, // clamp or wrap around when going beyond maximum/minimum setting
};
// The note numbers corresponding to the buttons in the matrix
const AddressMatrix<7, 8> addresses {{
{MIDI_Notes::C(6), MIDI_Notes::B(5), MIDI_Notes::Bb(5), MIDI_Notes::A(5), MIDI_Notes::Ab(5), MIDI_Notes::G(5), MIDI_Notes::Gb(5), MIDI_Notes::F_(5)},
{MIDI_Notes::E(5), MIDI_Notes::Eb(5), MIDI_Notes::D(5), MIDI_Notes::Db(5), MIDI_Notes::C(5), MIDI_Notes::B(4), MIDI_Notes::Bb(4), MIDI_Notes::A(4)},
{MIDI_Notes::Ab(4), MIDI_Notes::G(4), MIDI_Notes::Gb(4), MIDI_Notes::F_(4), MIDI_Notes::E(4), MIDI_Notes::Eb(4), MIDI_Notes::D(4), MIDI_Notes::Db(4)},
{MIDI_Notes::C(4), MIDI_Notes::B(3), MIDI_Notes::Bb(3), MIDI_Notes::A(3), MIDI_Notes::Ab(3), MIDI_Notes::G(3), MIDI_Notes::Gb(3), MIDI_Notes::F_(3)},
{MIDI_Notes::E(3), MIDI_Notes::Eb(3), MIDI_Notes::D(3), MIDI_Notes::Db(3), MIDI_Notes::C(3), MIDI_Notes::B(2), MIDI_Notes::Bb(2), MIDI_Notes::A(2)},
{MIDI_Notes::Ab(2), MIDI_Notes::G(2), MIDI_Notes::Gb(2), MIDI_Notes::F_(2), MIDI_Notes::E(2), MIDI_Notes::Eb(2), MIDI_Notes::D(2), MIDI_Notes::Db(2)},
{MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2), MIDI_Notes::C(2)},
}};
MultiBankNoteButtonMatrix<7, 8> buttonmatrix {
transposer,
{bank, BankType::CHANGE_CHANNEL},
{20, 19, 18, 15, 14, 16, 10}, // row pins
{2, 3, 4, 5, 6, 7, 8, 9}, // column pins
addresses, // address matrix
CHANNEL_1, // channel and cable number
};
// VELOCITY 7-bit filtered analog input for velocity control
FilteredAnalog<7> velocityInput = A3;
void setup() {
Control_Surface.begin();
buttonmatrix.setVelocity(100); //0..127 settaggio iniziale velocity
}
void loop() {
if (velocityInput.update())
buttonmatrix.setVelocity(velocityInput.getValue());
Control_Surface.loop();
} (Untested) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have transformed an old keyboard into a new midi keyboard with satisfying success. The keys work and I can transpose the notes. I would also like to change the midi channel.
In a Bankable::NoteButtonMatrix it is possible to use Transposer and {bank, BankType::CHANGE_CHANNEL} at the same time?
I create 2 bank selector , but i don't know how to use the second bank selector to change the channel.
Grazie
Mycode:
Beta Was this translation helpful? Give feedback.
All reactions