Midi Button Matrix is putting out wrong Notes

Hi!

I have a problem and i hope i get help here :slight_smile:

I want to use an old toy guitar as midicontroller.
It has 12 button switches on the neck and it uses a button matrix
with 3 columns and 4 rows.
I am using an Arduino Micro and want to be able to play 12 notes via
MidiUsb. (hooked up to the computer)

Now i wanted to use the “Ex.11 Button Matrix” code from the
Midi Controller Library, as it seems perfect for my needs:

a 4 x 3 matrix which puts out 12 chromatic tones.

So far so good, BUT no matter what i do, the arduino puts out
the same note as last note of a row AND as first note of the next row.
Like this:

C, C#, D, D#
D#, E, F, F#
F#, G, G#, A

instead of doing a chromatic scale.

this is the code used, taken from the Midi Controller Library
(https://github.com/tttapa/MIDI_controller/releases/tag/3.1.0)

/*
This is an example of the "ButtonMatrix" class of the MIDI_controller library.
Connect a 4 × 3 matrix of buttons with the rows to pins 2, 3, 4 and 5, 
and the columns to pins 6, 7 and 8.
Pull-up resistors are not necessary, because the internal ones will be used. 

If you want to be able to press multiple buttons at once, add a diode 
in series with each button, as shown in the schematic on the Wiki:
https://github.com/tttapa/MIDI_controller/wiki/Hardware

The note numbers are specified in the 'addresses' array.
Map accordingly in your DAW or DJ software.

Written by tttapa, 24/09/2017
https://github.com/tttapa/MIDI_controller
*/

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

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t addresses[4][3] = {   // the note numbers corresponding to the buttons in the matrix
  {  1,  2,  3 },
  {  4,  5,  6 },
  {  7,  8,  9 },
  { 10, 11, 12 }
};

// 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, 3> buttonmatrix({2, 3, 4, 5}, {6, 7, 8}, 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();
}

Thanks in advance!!! Any help highly appreciated

That's a bug indeed.
I fixed it in f4c4c2a.

Pieter

Thank you!!!!! :slight_smile:

PieterP:
That's a bug indeed.
I fixed it in f4c4c2a.

Pieter

Ok, i now changed the .cpp file
compiled the code and now i got a diminished scale like:

C, D#, G, C
C#, E, G#, C#
D, F, A, D

please help,sadly i am still a total noob with this :confused:

If a libraries been fixed, reinstall the whole library, not just one file.

Ok! I will do that!

Ok, i deleted the old Midi Controller Library, installed the new, but the problem is the same..
it puts out a diminished scale...

Ok, i figured it out myself!!
In case anybody has the same problem...
you have to change this:

const uint8_t addresses[4][3] = { // the note numbers corresponding to the buttons in the matrix
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 },
{ 10, 11, 12 }

into this

const uint8_t addresses[4][3] = { // the note numbers corresponding to the buttons in the matrix
{ 1, 5, 9 },
{ 2, 6, 10 },
{ 3, 7, 11 },
{ 4, 8, 12 }

Great to hear!