Alright !
Solution found :
BEGIN_CS_NAMESPACE
namespace Bankable {
/**
* @brief An abstract class for momentary push buttons that send MIDI events.
*
* The button is debounced.
*
* @see Button
*/
template <class BankAddress, class Sender>
class DoubleBanksMIDIButton : public MIDIOutputElement {
public:
/**
* @brief Construct a new bankable MIDIButton.
*
* @param channel_bankAddress
* The bankable MIDI address to send to.
* @param note_bankAddress
* The bankable MIDI address to send to.
* @param pin
* The digital input pin with the button connected.
* The internal pull-up resistor will be enabled.
* @param sender
* The MIDI sender to use.
*/
DoubleBanksMIDIButton(BankAddress channel_bankAddress, BankAddress note_bankAddress, pin_t pin, const Sender &sender)
: channel_address(channel_bankAddress), note_address(note_bankAddress), button(pin), sender(sender) {}
void begin() override { button.begin(); }
void update() override {
Button::State state = button.update();
if (state == Button::Falling) {
channel_address.lock();
note_address.lock();
sender.sendOn(channel_address.getActiveAddress() + RelativeMIDIAddress(note_address.getActiveAddress().getAddress() - channel_address.getActiveAddress().getAddress()));
} else if (state == Button::Rising) {
sender.sendOff(channel_address.getActiveAddress() + RelativeMIDIAddress(note_address.getActiveAddress().getAddress() - channel_address.getActiveAddress().getAddress()));
channel_address.unlock();
note_address.unlock();
}
}
/// @see @ref Button::invert()
void invert() { button.invert(); }
Button::State getButtonState() const { return button.getState(); }
protected:
BankAddress channel_address;
BankAddress note_address;
Button button;
public:
Sender sender;
};
/**
* @brief A class of MIDIOutputElement%s that read the input of a **momentary
* push button or switch**, and send out MIDI **Note** events.
*
* A Note On event is sent when the button is pressed, and a Note Off
* event is sent when the button is released.
* The button is debounced in software.
* This version can be banked.
*
* @ingroup BankableMIDIOutputElements
*/
class DoubleBanksNoteButton : public DoubleBanksMIDIButton<SingleAddress, DigitalNoteSender> {
public:
/**
* @brief Create a new Bankable NoteButton object with the given pin, note
* number and channel.
*
* @param channel_config
* The bank configuration to use: the bank to add this element to,
* and whether to change the address, channel or cable number.
* @param note_config
* The bank configuration to use: the bank to add this element to,
* and whether to change the address, channel or cable number.
* @param pin
* The digital input pin to read from.
* The internal pull-up resistor will be enabled.
* @param address
* The MIDI address containing the note number [0, 127],
* channel [Channel_1, Channel_16], and optional cable number
* [Cable_1, Cable_16].
* @param velocity
* The velocity of the MIDI Note events.
*/
DoubleBanksNoteButton(OutputBankConfig<> channel_config, OutputBankConfig<> note_config, pin_t pin, MIDIAddress address,
uint8_t velocity = 0x7F)
: DoubleBanksMIDIButton<SingleAddress, DigitalNoteSender> {
{channel_config, address},
{note_config, address},
pin,
{velocity},
} {}
/// Set the velocity of the MIDI Note events.
void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
/// Get the velocity of the MIDI Note events.
uint8_t getVelocity() const { return this->sender.getVelocity(); }
};
} // namespace Bankable
END_CS_NAMESPACE
// Instantiate a MIDI over USB interface
USBMIDI_Interface midi;
uint8_t initChannel = 4;
Transposer<-2, +2> transposer(12);
// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> transposerSelector {
transposer,
{34, 35},
Wrap::Clamp, // Wrap around
};
Bank<16> channel(1);
// Instantiate a Bank selector to control which one of the four Banks is active.
IncrementDecrementSelector<channel.getNumberOfBanks()> channelSelector {
channel, // Bank to manage
{25, 27}, // push button pins (increment, decrement)
Wrap::Clamp, // Wrap around
};
Bankable::DoubleBanksNoteButton buttons[] {
{{channel, BankType::ChangeChannel}, {transposer, BankType::ChangeAddress}, 33, {MIDI_Notes::C[4]}},
};
Just had to inherit few classes 