Go Down

Topic: Two instances of MIDI library (Read 945 times) previous topic - next topic



I'm using MIDI.h with a Sparkfun midishield plugged into an Arduino mega. Since the mega has more than one set of serial ports, I've connected the midishield to serial1 using 2 bits of wire, so I don't have to remember to move the switch that's provided each time I upload one of my buggy programs.

MIDI.h is a bit more complicated than the written-out code that comes with the midishield, but it minimises the dreaded MIDI latency problem by using interrups.

It was easy enough to edit MIDI.h to change the serial setting as instructed, and everything works fine :). However, I wanted to change the library name to something like MIDI1.h so as not to forget that I have messed around with my copy. That caused my sketch to crash. No great problem even for my tiny brain, except that soon I'd like to piggyback a second midishield, using serial2, and so run two instances of MIDI.h which would definitely need separate library names.

In addition to my own Arduino project, I'd then be able to make a 2-in 2-out USB/MIDI interface/filter for the price of the extra midishield (or MIDI breakout).

Before I start taking the trouble of working it out, please could anyone indicate which lines I should change in MIDI.h to match the new library names?

Go Up