Problem with midi.send - midi library

Hi,

I am new to the arduino world, and I LOVE IT! :slight_smile:

I am building a Midi- Footcontroller for my guitar-rig and it´s working quite good, but now i have a problem.

I am using the midi library and want to use the midi.send command... the arduino should send midi-commands of different types.. and the different types are in an array.

but:
Before thinking of arrays, i tried to just send a mid program change message with "midi.send" with no success...:
in the documentation of the library it says ProgramChange = 0xC0

this code:

#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);

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

void loop()
{
        MIDI.send(0xC0, 10, 0, 1);  
        delay(1000);
}

results in an error:
invalid conversion from 'int' to 'midi::MidiType' [-fpermissive] ...

Same with MIDI.send(192, 10, 0, 1);

when i try
MIDI.send(ProgramChange, 10, 0, 1);

i get this error:
IDI_sendproblem.ino: In function 'void loop()':
MIDI_sendproblem.ino:13:19: error: 'ProgramChange' was not declared in this scope
MIDI_sendproblem.ino:13:19: note: suggested alternative:
In file included from /Users/mortl/Documents/Arduino/libraries/MIDI/MIDI.h:26:0,
from MIDI_sendproblem.ino:1:
/Users/mortl/Documents/Arduino/libraries/MIDI/midi_Defs.h:63:5: note: 'ProgramChange'
ProgramChange = 0xC0, ///< Program Change
^

As said, later the type of the message should be in an array to be able to send different types of messages in one loop.

any ideas?

thanks
Martin

Got it:

you have to use
MIDI.send(midi::ProgramChange, 10, 0, 1);

greetings
Martin

Ok, but what if you I want to have MIDI type as variable? It requests kMIDIType? I goal is to read MIDI type from EEPROM.

byte dat1;
byte dat2;
byte kan;

Works fine, there is only problem with MIDI type. I'm trying to find solution for few days. Should I play with library ?

#include <MIDI.h>

byte type;  // It requests kMIDIType
byte dat1;
byte dat2;
byte kan;


MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);

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

void loop()
{
        MIDI.send(midi::type, dat1, dat2, kan);  
        delay(1000);
}