tttapa / MIDI_controller

This is a library for creating a MIDI controller using an Arduino or Teensy board.
GNU General Public License v3.0
404 stars 69 forks source link

2 adresses for 1 button matrix #66

Open kokolasticot opened 5 years ago

kokolasticot commented 5 years ago

Description of the problem or question

Hi, I'am trying to creat a MIDI diatonic accordion (it has two notes for one button depending on pushing or pulling the air). I read a lot on your well documented library but i can't find how to (if it is possible) have a button matrix pointing on two different adresses. I found the solution to change the channel with an offset of 1 and just listening the chanel 2 on my PC, that works. Nevertheless i recive the 2 notes (atributed to one button) . Is there any other solution because if i releas the "air button" before the note it never stop to play? I hope i am clear enought.

Steps to reproduce the problem

Hardware

arduino UNO

Full code

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

USBSerialMIDI_Interface midiInterface(115200);
const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)

const int TP = 12;//emulating the push/pull

const uint8_t addressesPush[4][1] = {   // the note numbers corresponding to the buttons in the matrix
  { 62 },
  { 67 },
  { 72 },
  { 76 }};
ButtonMatrix<4, 1> buttonmatrixPush({3, 4, 5, 6}, {2}, addressesPush, 2, velocity) ;

const uint8_t addressesPull[4][1] = {   // the note numbers corresponding to the buttons in the matrix
  { 64 },
  { 66 },
  { 69 },
  { 72 }};
ButtonMatrix<4, 1> buttonmatrixPull({3, 4, 5, 6}, {2}, addressesPull, 1, velocity);

Bank bank(1);

void setup() {
  pinMode(TP, INPUT);
  bank.add(buttonmatrixPull, Bank::CHANGE_CHANNEL); 
  bank.add(buttonmatrixPush, Bank::CHANGE_CHANNEL);
}
void loop() {
  if (digitalRead(TP) == LOW) {
    bank.setBankSetting(1);
  }
  else {
    bank.setBankSetting(0);
  }
  MIDI_Controller.refresh();
}

The goal of your project and aditional information

Romek1234 commented 3 years ago

Arduino UNO.

I have a very similar problem. I have two keyboards: one matrix keyboard: 8x4 and the other matrix keyboard: 2x2 and I want both to work on different midi channels. A single-keyboard program works fine. After adding the second table to the code - the code compiles correctly and nothing works after uploading to arduino uno, i.e. it does not send any midi messages.

include

/* The diodes conduct towards the pins A0 A1...

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 addresses1[2][2] = { // 4 wiersze 8 kolumn the note numbers corresponding to the buttons in the matrix

{ 58, 59 }, { 66, 67 }

}; const uint8_t addresses[4][8] = { // 4 wiersze 8 kolumn the note numbers corresponding to the buttons in the matrix { 36, 37, 38, 39, 40, 41, 42, 43 }, { 44, 45, 46, 47, 48, 49, 50, 51 }, { 52, 53, 54, 55, 56, 57, 58, 59 }, { 60, 61, 62, 63, 64, 65, 66, 67 } };

// 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, 8> buttonmatrix( {A0, A1, A2, A3}, {3, 4, 5, 6, 7, 8, 9, 10}, addresses, 2, velocity); ButtonMatrix<2, 2> buttonmatrix1( {A4, A5}, {11, 12}, addresses1, 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(); }

https://github.com/Romek1234/Double-matrix-keyboard-and-one-arduino