Access MIDI instance from another class

Status
Not open for further replies.

djex81

Active member
I'm using the MIDI.h library. After using MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI) how do I access the MIDI instance from another class? MIDI_CREATE_INSTANCE does not return an instance of MIDI.
 
Its called MIDI because you just named it as such. MIDI_CREATE_INSTANCE is a macro that defines an instance
with the name you give it (last argument to the macro).
 
I'm using the MIDI.h library. After using MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI) how do I access the MIDI instance from another class? MIDI_CREATE_INSTANCE does not return an instance of MIDI.

@djex81:

The third parameter that you are passing into the MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI) macro specifies & holds the return of your default MIDI object name, which can subsequently be referenced by "MIDI.xxx()" [e.g. MIDI.begin(MIDI_CHANNEL_OMNI)].

Mark J Culross
KD5RXT

EDIT: Whoops . . . looks like MarkT typed & posted faster than I did !! MJC
 
Last edited:
@djex81:

The third parameter that you are passing into the MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI) macro specifies & holds the return of your default MIDI object name, which can subsequently be referenced by "MIDI.xxx()" [e.g. MIDI.begin(MIDI_CHANNEL_OMNI)].

Mark J Culross
KD5RXT

EDIT: Whoops . . . looks like MarkT typed & posted faster than I did !! MJC

Right I understand this but how would I access MIDI from another class? or in my case globally? I've tried to set it up in a header file and include that header where I needed but I get multiple definition errors. There are no issues with using the usbMIDI library as this can be accessed from any class I have. Not sure why I can not with MIDI.h

Edit: Never mind. I've figured it out.
 
Last edited:
Status
Not open for further replies.
Back
Top