Help with 16 button MIDI controller

Please Help.
I have this 16 button keyboard which is on picture.

I want Midi controller that 2 buttons will be octave switcher (UP and DOWN). It is possible? I have this code so far:

#include "MIDI_Controller.h" // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t addresses[4][4] = {   // the note numbers corresponding to the buttons in the matrix
  {  48,  49,  50,  51 },
  {  44,  45,  46,  47 },
  {  40,  41,  42,  43 },
  { 36,  37,  38,  39 }
};

// Create a new instance of the class 'ButtonMatrix', called 'buttonmatrix', with dimensions 4 rows and 3 columns, with the rows connected to pins 2, 3, 4 and 5
// and the columns connected to pins 6, 7 and 8, that sends MIDI messages with the notes specified in 'addresses' on MIDI channel 1, with velocity 127
ButtonMatrix<4, 4> buttonmatrix({2, 3, 4, 5}, {6, 7, 8, 9}, addresses, 1, velocity);

void setup() {}

void loop() {
  // Refresh the buttons (check whether the states have changed since last time, if so, send it over MIDI)
  MIDI_Controller.refresh();
}

Where is the MIDI coming from?
You can only shift up / down by adding 12 or -12 to the MIDI note on and note off numbers.

What Arduino do you have and how are you connecting it to what MIDI device?

1 Like

I no longer offer support for the MIDI controller library, it has long been replaced by the Control Surface library.

The button matrix code is still very similar, see NoteButtonMatrix.ino.

To shift up and down an octave, you can use a Transposer.

For example:

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

// Instantiate a Transposer that can transpose from one octave down to one
// octave up (in steps of 12 semitones = 1 octave)
Transposer<-1, +1> transposer(12);

// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector = {
  transposer,
  {10, 11},    // button on pin 10 increments, pin 11 decrements
  Wrap::Clamp,
};

// The note numbers corresponding to the buttons in the matrix
const AddressMatrix<4, 4> addresses  = {{
  { 48,  49,  50,  51 },
  { 44,  45,  46,  47 },
  { 40,  41,  42,  43 },
  { 36,  37,  38,  39 },
}};

Bankable::NoteButtonMatrix<4, 4> buttonmatrix = {
  transposer,   // transpose the note numbers
  {2, 3, 4, 5}, // row pins
  {6, 7, 8, 9}, // column pins
  addresses,    // address matrix
  CHANNEL_1,    // channel and optional cable number
};

void setup() {
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}

Pieter

Thank you very much :slight_smile:

please, and couldn't it be done that the transposer wasn't on pin 10, 11, but would it be two buttons from the mattrix?

vespo:
please, and couldn't it be done that the transposer wasn't on pin 10, 11, but would it be two buttons from the mattrix?

That's not supported out of the box. But there's no reason why you couldn't program that in yourself, of course.

please can you help me with changing the channel? one button channel up and the other channel down?

"Report to moderator" is NOT a reply option.

sorry, i didnt know it........I clicked badly, was in a hurry I just wanted to add a new comment, sorry