Midi Controller

IDE gerelateerde berichten
Berichten: 2
Geregistreerd: 12 Okt 2018, 19:34

Midi Controller

Berichtdoor Tom1234567789 » 12 Okt 2018, 19:40

ik heb een code proberen te maken met 7 multiplexers van elk 16 kanalen 4x digitaal en 3x analoog maar krijg de code niet goed wie kan helpen het board is de arduino Mega 2560
dit is de code:

// arduino_midi_library - Version: Latest
#include <MIDI.h>

// MIDI - Version: Latest
#include <MIDI.h>
#include "Controller.h"


/*************************************************************
MIDI CONTROLLER



Version 1.2
*************************************************************/

MIDI_CREATE_DEFAULT_INSTANCE();

//************************************************************
//***SET THE NUMBER OF CONTROLS USED**************************
//************************************************************
//---How many buttons are connected directly to pins?---------
byte NUMBER_BUTTONS = 20;
//---How many potentiometers are connected directly to pins?--
byte NUMBER_POTS = 5;
//---How many buttons are connected to a multiplexer?---------
byte NUMBER_MUX_BUTTONS = 16;
//---How many potentiometers are connected to a multiplexer?--
byte NUMBER_MUX_POTS = 16;
//************************************************************

//***ANY MULTIPLEXERS? (74HC4067)************************************
//MUX address pins must be connected to Arduino UNO pins 2,3,4,5
//A0 = PIN2, A1 = PIN3, A2 = PIN4, A3 = PIN5
//*******************************************************************
//Mux NAME (OUTPUT PIN, , How Many Mux Pins?(8 or 16) , Is It Analog?);


Mux M1(A1, 16, true); //Analog multiplexer on Arduino analog pin A0
Mux M2(A2, 16, true); //Analog multiplexer on Arduino analog pin A1
Mux M3(A3, 16, true); //Analog multiplexer on Arduino analog pin A2
Mux M6(10, 16, false); //Digital multiplexer on Arduino pin 9
Mux M7(11, 16, false); //Digital multiplexer on Arduino pin 10
Mux M8(12, 16, false); //Digital multiplexer on Arduino pin 11
Mux M9(12, 16, false); //Digital multiplexer on Arduino pin 12
//*******************************************************************


//***DEFINE DIRECTLY CONNECTED POTENTIOMETERS************************
//Pot (Pin Number, Command, CC Control, Channel Number)
//**Command parameter is for future use**

Pot PO1(A10, 0, 1, 1);
Pot PO2(A12, 0, 2, 1);
Pot PO3(A13, 0, 3, 1);
Pot PO4(A14, 0, 4, 1);
Pot PO5(A15, 0, 5, 1);
//Pot PO6(A5, 0, 6, 1);
//*******************************************************************
//Add pots used to array below like this-> Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5, &PO6};
Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5};
//********************************************************************


//***DEFINE POTENTIOMETERS CONNECTED TO MULTIPLEXER*******************
//Pot::Pot(Mux mux, byte muxpin, byte command, byte control, byte channel)
//**Command parameter is for future use**

Pot MPO1(M1, 0, 0, 1, 1);
Pot MPO2(M1, 1, 0, 2, 1);
Pot MPO3(M1, 2, 0, 3, 1);
Pot MPO4(M1, 3, 0, 4, 1);
Pot MPO5(M1, 4, 0, 5, 1);
Pot MPO6(M1, 5, 0, 6, 1);
Pot MPO7(M1, 6, 0, 7, 1);
Pot MPO8(M1, 7, 0, 8, 1);
Pot MPO9(M1, 8, 0, 9, 1);
Pot MPO10(M1, 9, 0, 10, 1);
Pot MPO11(M1, 10, 0, 11, 1);
Pot MPO12(M1, 11, 0, 12, 1);
Pot MPO13(M1, 12, 0, 13, 1);
Pot MPO14(M1, 13, 0, 14, 1);
Pot MPO15(M1, 14, 0, 15, 1);
Pot MPO16(M1, 15, 0, 16, 1);
//*******************************************************************
//Add multiplexed pots used to array below like this-> Pot *MUXPOTS[] {&MPO1, &MPO2, &MPO3, &MPO4, &MPO5, &MPO6.....};
Pot *MUXPOTS[] {&MPO1, &MPO2, &MPO3, &MPO4, &MPO5, &MPO6, &MPO7, &MPO8, &MPO9, &MPO10, &MPO11, &MPO12, &MPO13, &MPO14, &MPO15, &MPO16};
//*******************************************************************



//***DEFINE POTENTIOMETERS CONNECTED TO MULTIPLEXER*******************
//Pot::Pot(Mux mux, byte muxpin, byte command, byte control, byte channel)
//**Command parameter is for future use**

Pot MPO17(M2, 0, 0, 17, 2);
Pot MPO18(M2, 1, 0, 18, 2);
Pot MPO19(M2, 2, 0, 19, 2);
Pot MPO20(M2, 3, 0, 20, 2);
Pot MPO21(M2, 4, 0, 21, 2);
Pot MPO22(M2, 5, 0, 22, 2);
Pot MPO23(M2, 6, 0, 23, 2);
Pot MPO24(M2, 7, 0, 24, 2);
Pot MPO25(M2, 8, 0, 25, 2);
Pot MPO26(M2, 9, 0, 26, 2);
Pot MPO27(M2, 10, 0, 27, 2);
Pot MPO28(M2, 11, 0, 28, 2);
Pot MPO29(M2, 12, 0, 29, 2);
Pot MPO30(M2, 13, 0, 30, 2);
Pot MPO31(M2, 14, 0, 31, 2);
Pot MPO32(M2, 15, 0, 32, 2);
//*******************************************************************
//Add multiplexed pots used to array below like this-> Pot *MUXPOTS[] {&MPO1, &MPO2, &MPO3, &MPO4, &MPO5, &MPO6.....};
Pot *MUXPOTS1 [] {&MPO17, &MPO18, &MPO19, &MPO20, &MPO21, &MPO22, &MPO23, &MPO24, &MPO25, &MPO26, &MPO27, &MPO28, &MPO29, &MPO30, &MPO31, &MPO32};
//*******************************************************************

//***DEFINE POTENTIOMETERS CONNECTED TO MULTIPLEXER*******************
//Pot::Pot(Mux mux, byte muxpin, byte command, byte control, byte channel)
//**Command parameter is for future use**

Pot MPO33(M3, 0, 0, 1, 3);
Pot MPO34(M3, 1, 0, 2, 3);
Pot MPO35(M3, 2, 0, 3, 3);
Pot MPO36(M3, 3, 0, 4, 3);
Pot MPO37(M3, 4, 0, 5, 3);
Pot MPO38(M3, 5, 0, 6, 3);
Pot MPO39(M3, 6, 0, 7, 3);
Pot MPO40(M3, 7, 0, 8, 3);
Pot MPO41(M3, 8, 0, 9, 3);
Pot MPO42(M3, 9, 0, 10, 3);
Pot MPO43(M3, 10, 0, 11, 3);
Pot MPO44(M3, 11, 0, 12, 3);
Pot MPO45(M3, 12, 0, 13, 3);
Pot MPO46(M3, 13, 0, 14, 3);
Pot MPO47(M3, 14, 0, 15, 3);
Pot MPO48(M3, 15, 0, 16, 3);
//******************************************************************
//Add multiplexed pots used to array below like this-> Pot *MUXPOTS[] {&MPO1, &MPO2, &MPO3, &MPO4, &MPO5, &MPO6.....};
Pot *MUXPOTS2[] {&MPO33, &MPO34, &MPO35, &MPO36, &MPO37, &MPO38, &MPO39, &MPO40, &MPO41, &MPO42, &MPO43, &MPO44, &MPO45, &MPO46, &MPO47, &MPO48};
//*******************************************************************

//***DEFINE POTENTIOMETERS CONNECTED TO MULTIPLEXER*******************
//Pot::Pot(Mux mux, byte muxpin, byte command, byte control, byte channel)
//**Command parameter is for future use**

Pot MPO50(M2, 0, 0, 1, 4);
Pot MPO51(M2, 1, 0, 2, 4);
Pot MPO52(M2, 2, 0, 3, 4);
Pot MPO53(M2, 3, 0, 4, 4);
Pot MPO54(M2, 4, 0, 5, 4);
Pot MPO55(M2, 5, 0, 6, 4);
Pot MPO56(M2, 6, 0, 7, 4);
Pot MPO57(M2, 7, 0, 8, 4);
Pot MPO58(M2, 8, 0, 9, 4);
Pot MPO59(M2, 9, 0, 10, 4);
Pot MPO60(M2, 10, 0, 11, 4);
Pot MPO61(M2, 11, 0, 12, 4);
Pot MPO62(M2, 12, 0, 13, 4);
Pot MPO63(M2, 13, 0, 14, 4);
Pot MPO64(M2, 14, 0, 15, 4);
Pot MPO65(M2, 15, 0, 16, 4);
//******************************************************************
//Add multiplexed pots used to array below like this-> Pot *MUXPOTS[] {&MPO1, &MPO2, &MPO3, &MPO4, &MPO5, &MPO6.....};
Pot *MUXPOTS3[] {&MPO50, &MPO51, &MPO52, &MPO53, &MPO54, &MPO55, &MPO56, &MPO57, &MPO58, &MPO59, &MPO60, &MPO61, &MPO62, &MPO63, &MPO64, &MPO65};
//*******************************************************************

//***DEFINE DIRECTLY CONNECTED BUTTONS*******************************
//Button (Pin Number, Command, Note Number, Channel, Debounce Time)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **

Button BU1(49, 0, 1, 5, 5);
Button BU2(48, 0, 2, 5, 5);
Button BU3(47, 0, 3, 5, 5);
Button BU4(46, 0, 4, 5, 5);
Button BU5(45, 0, 5, 5, 5);
Button BU6(44, 0, 6, 5, 5);
Button BU7(43, 0, 7, 5, 5);
Button BU8(42, 0, 8, 5, 5);
Button BU9(41, 0, 9, 5, 5);
Button BU10(40, 0, 10, 5, 5);
Button BU11(39, 0, 11, 5, 5);
Button BU12(38, 0, 12, 5, 5);
Button BU13(37, 0, 13, 5, 5);
Button BU14(36, 0, 14, 5, 5);
Button BU15(34, 0, 15, 5, 5);
Button BU16(33, 0, 16, 5, 5);
//*******************************************************************
//Add buttons used to array below like this-> Button *BUTTONS[] {&BU1, &BU2, &BU3, &BU4, &BU5, &BU6, &BU7, &BU8};
Button *BUTTONS[] {&BU1, &BU2, &BU3, &BU4, &BU5, &BU6, &BU7, &BU8, &BU9, &BU10, &BU11, &BU12, &BU13, &BU14, &BU15, &BU16};

//*******************************************************************


//***DEFINE BUTTONS CONNECTED TO MULTIPLEXER*************************
//Button::Button(Mux mux, byte muxpin, byte command, byte value, byte channel, byte debounce)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **

Button MBU17(M6, 0, 0, 1, 6, 5);
Button MBU18(M6, 1, 0, 2, 6, 5);
Button MBU19(M6, 2, 0, 3, 6, 5);
Button MBU20(M6, 3, 0, 4, 6, 5);
Button MBU21(M6, 4, 0, 5, 6, 5);
Button MBU22(M6, 5, 0, 6, 6, 5);
Button MBU23(M6, 6, 0, 7, 6, 5);
Button MBU24(M6, 7, 0, 8, 6, 5);
Button MBU25(M6, 8, 0, 9, 6, 5);
Button MBU26(M6, 9, 0, 10, 6, 5);
Button MBU27(M6, 10, 0, 11, 6, 5);
Button MBU28(M6, 11, 0, 12, 6, 5);
Button MBU29(M6, 12, 0, 13, 6, 5);
Button MBU30(M6, 13, 0, 14, 6, 5);
Button MBU31(M6, 14, 0, 15, 6, 5);
Button MBU32(M6, 15, 0, 16, 6, 5);
//*******************************************************************
////Add multiplexed buttons used to array below like this-> Button *MUXBUTTONS[] {&MBU1, &MBU2, &MBU3, &MBU4, &MBU5, &MBU6.....};
Button *MUXBUTTONS[] {&MBU17, &MBU18, &MBU19, &MBU20, &MBU21, &MBU22, &MBU23, &MBU24, &MBU25, &MBU26, &MBU27, &MBU28, &MBU29, &MBU30, &MBU31, &MBU32};

//*******************************************************************


//***DEFINE BUTTONS CONNECTED TO MULTIPLEXER*************************
//Button::Button(Mux mux, byte muxpin, byte command, byte value, byte channel, byte debounce)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **

Button MBU33(M7, 0, 0, 1, 7, 5);
Button MBU34(M7, 1, 0, 2, 7, 5);
Button MBU35(M7, 2, 0, 3, 7, 5);
Button MBU36(M7, 3, 0, 4, 7, 5);
Button MBU37(M7, 4, 0, 5, 7, 5);
Button MBU38(M7, 5, 0, 6, 7, 5);
Button MBU39(M7, 6, 0, 7, 7, 5);
Button MBU40(M7, 7, 0, 8, 7, 5);
Button MBU41(M7, 8, 0, 9, 7, 5);
Button MBU42(M7, 9, 0, 10, 7, 5);
Button MBU43(M7, 10, 0, 11, 7, 5);
Button MBU44(M7, 11, 0, 12, 7, 5);
Button MBU45(M7, 12, 0, 13, 7, 5);
Button MBU46(M7, 13, 0, 14, 7, 5);
Button MBU47(M7, 14, 0, 15, 7, 5);
Button MBU48(M7, 15, 0, 16, 7, 5);
//*******************************************************************
////Add multiplexed buttons used to array below like this-> Button *MUXBUTTONS[] {&MBU1, &MBU2, &MBU3, &MBU4, &MBU5, &MBU6.....};
Button* MUXBUTTONS2[] {&MBU33, &MBU34, &MBU35, &MBU36, &MBU37, &MBU38, &MBU39, &MBU40, &MBU41, &MBU42, &MBU43, &MBU44, &MBU45, &MBU46, &MBU47, &MBU47};



//***DEFINE BUTTONS CONNECTED TO MULTIPLEXER*************************
//Button::Button(Mux mux, byte muxpin, byte command, byte value, byte channel, byte debounce)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **

Button MBU49(M8, 0, 0, 1, 8, 5);
Button MBU50(M8, 1, 0, 2, 8, 5);
Button MBU51(M8, 2, 0, 3, 8, 5);
Button MBU52(M8, 3, 0, 4, 8, 5);
Button MBU53(M8, 4, 0, 5, 8, 5);
Button MBU54(M8, 5, 0, 6, 8, 5);
Button MBU55(M8, 6, 0, 7, 8, 5);
Button MBU56(M8, 7, 0, 8, 8, 5);
Button MBU57(M8, 8, 0, 9, 8, 5);
Button MBU58(M8, 9, 0, 10, 8, 5);
Button MBU59(M8, 10, 0, 11, 8, 5);
Button MBU60(M8, 11, 0, 12, 8, 5);
Button MBU61(M8, 12, 0, 13, 8, 5);
Button MBU62(M8, 13, 0, 14, 8, 5);
Button MBU63(M8, 14, 0, 15, 8, 5);
Button MBU64(M8, 15, 0, 16, 8, 5);
//*******************************************************************
////Add multiplexed buttons used to array below like this-> Button *MUXBUTTONS[] {&MBU1, &MBU2, &MBU3, &MBU4, &MBU5, &MBU6.....};
Button *MUXBUTTONS3[] {&MBU49, &MBU50, &MBU51, &MBU52, &MBU53, &MBU54, &MBU55, &MBU56, &MBU57, &MBU58, &MBU59, &MBU60, &MBU61, &MBU62, &MBU63, &MBU64};



//***DEFINE BUTTONS CONNECTED TO MULTIPLEXER*************************
//Button::Button(Mux mux, byte muxpin, byte command, byte value, byte channel, byte debounce)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **

Button MBU65(M9, 0, 0, 1, 9, 5);
Button MBU66(M9, 1, 0, 2, 9, 5);
Button MBU67(M9, 2, 0, 3, 9, 5);
Button MBU68(M9, 3, 0, 4, 9, 5);
Button MBU69(M9, 4, 0, 5, 9, 5);
Button MBU70(M9, 5, 0, 6, 9, 5);
Button MBU71(M9, 6, 0, 7, 9, 5);
Button MBU72(M9, 7, 0, 8, 9, 5);
Button MBU73(M9, 8, 0, 9, 9, 5);
Button MBU74(M9, 9, 0, 10, 9, 5);
Button MBU75(M9, 10, 0, 11, 9, 5);
Button MBU76(M9, 11, 0, 12, 9, 5);
Button MBU77(M9, 12, 0, 13, 9, 5);
Button MBU78(M9, 13, 0, 14, 9, 5);
Button MBU79(M9, 14, 0, 15, 9, 5);
Button MBU80(M9, 15, 0, 16, 9, 5);
//*******************************************************************

////Add multiplexed buttons used to array below like this-> Button *MUXBUTTONS[] {&MBU1, &MBU2, &MBU3, &MBU4, &MBU5, &MBU6.....};
Button *MUXBUTTONS4[] {&MBU65, &MBU66, &MBU67, &MBU68, &MBU69, &MBU70, &MBU71, &MBU72, &MBU73, &MBU74, &MBU75, &MBU76, &MBU77, &MBU78, &MBU79, &MBU80};

void setup() {
MIDI.begin(MIDI_CHANNEL_OFF);
}

void loop() {
if (NUMBER_BUTTONS != 0) updateButtons();
if (NUMBER_POTS != 0) updatePots();
if (NUMBER_MUX_BUTTONS != 0) updateMuxButtons();
if (NUMBER_MUX_POTS != 0) updateMuxPots();
}

void muxbuttons2() {

}

//*****************************************************************
void updateButtons() {

// Cycle through Button array
for (int i = 0; i < NUMBER_BUTTONS; i = i + 1) {
byte message = BUTTONS[i]->getValue();

// Button is pressed
if (message == 0) {
switch (BUTTONS[i]->Bcommand) {
case 0: //Note
MIDI.sendNoteOn(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 1: //CC
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 2: //Toggle
if (BUTTONS[i]->Btoggle == 0) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 1;
}
else if (BUTTONS[i]->Btoggle == 1) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
break;
}
}

// Button is not pressed
if (message == 1) {
switch (BUTTONS[i]->Bcommand) {
case 0:
MIDI.sendNoteOff(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
case 1:
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
}
}
}
}
//*******************************************************************
void updateMuxButtons() {

// Cycle through Mux Button array
for (int i = 0; i < NUMBER_MUX_BUTTONS; i = i + 1) {

MUXBUTTONS[i]->muxUpdate();
byte message = MUXBUTTONS[i]->getValue();

// Button is pressed
if (message == 0) {
switch (MUXBUTTONS[i]->Bcommand) {
case 0: //Note
MIDI.sendNoteOn(MUXBUTTONS[i]->Bvalue, 127, MUXBUTTONS[i]->Bchannel);
break;
case 1: //CC
MIDI.sendControlChange(MUXBUTTONS[i]->Bvalue, 127, MUXBUTTONS[i]->Bchannel);
break;
case 2: //Toggle
if (MUXBUTTONS[i]->Btoggle == 0) {
MIDI.sendControlChange(MUXBUTTONS[i]->Bvalue, 127, MUXBUTTONS[i]->Bchannel);
MUXBUTTONS[i]->Btoggle = 1;
}
else if (MUXBUTTONS[i]->Btoggle == 1) {
MIDI.sendControlChange(MUXBUTTONS[i]->Bvalue, 0, MUXBUTTONS[i]->Bchannel);
MUXBUTTONS[i]->Btoggle = 0;
}
break;
}
}
// Button is not pressed
if (message == 1) {
switch (MUXBUTTONS[i]->Bcommand) {
case 0:
MIDI.sendNoteOff(MUXBUTTONS[i]->Bvalue, 0, MUXBUTTONS[i]->Bchannel);
break;
case 1:
MIDI.sendControlChange(MUXBUTTONS[i]->Bvalue, 0, MUXBUTTONS[i]->Bchannel);
break;
}
}
}
}
//***********************************************************************
void updatePots() {
for (int i = 0; i < NUMBER_POTS; i = i + 1) {
byte potmessage = POTS[i]->getValue();
if (potmessage != 255) MIDI.sendControlChange(POTS[i]->Pcontrol, potmessage, POTS[i]->Pchannel);
}
}
//***********************************************************************
void updateMuxPots() {



for (int i = 0; i < NUMBER_MUX_POTS; i = i + 1) {
MUXPOTS[i]->muxUpdate();
byte potmessage = MUXPOTS[i]->getValue();
if (potmessage != 255) MIDI.sendControlChange(MUXPOTS[i]->Pcontrol, potmessage, MUXPOTS[i]->Pchannel);

void updateMuxPots2() {



for (int i = 0; i < NUMBER_MUX_POTS; i = i + 1) {
MUXPOTS2[i]->muxUpdate();
byte potmessage = MUXPOTS2[i]->getValue();
if (potmessage != 255) MIDI.sendControlChange(MUXPOTS2[i]->Pcontrol, potmessage, MUXPOTS2[i]->Pchannel);

void updateMuxPots3() {



for (int i = 0; i < NUMBER_MUX_POTS; i = i + 1) {
MUXPOTS2[i]->muxUpdate();
byte potmessage = MUXPOTS3[i]->getValue();
if (potmessage != 255) MIDI.sendControlChange(MUXPOTS3[i]->Pcontrol, potmessage, MUXPOTS3[i]->Pchannel);
}
}
Bijlagen
MIDI_Controller_v1-2_without_bleuthooth.zip
(5.54 KiB) 19 keer gedownload

Advertisement

Berichten: 2491
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Midi Controller

Berichtdoor shooter » 15 Okt 2018, 19:36

check je mux M9 daar staat een typefout
check de muxpots same problem gebruik MUXPOTS1 etc.
gebruik CTRL T
wat is ->?
paul deelen
shooter@home.nl

Berichten: 2
Geregistreerd: 12 Okt 2018, 19:34

Re: Midi Controller

Berichtdoor Tom1234567789 » 16 Okt 2018, 18:54

Bedankt voor de reactie maar heb op een of andere manier een of andere stoor iets op de midi out hij schrijft als het ware zelf een midi knop en die schakelt de hele tijd

Terug naar Arduino IDE

Wie is er online?

Gebruikers in dit forum: Bing [Bot] en 2 gasten