-1

Error message :

"error: invalid declarator before 'MIDI'
         MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
                                                       ^
Plusieurs bibliothèque trouvées pour "libMidi.h"
/home/due32/Arduino/libraries/MIDI/midi_Defs.h:170:31: note: in definition of macro 'MIDI_CREATE_INSTANCE'
     midi::MidiInterface<Type> Name((Type&)SerialPort);"

libMidi.h

#ifndef libMidi_h
#define libMidi_h

#include <Arduino.h>
#include <MIDI.h>



    void midiSetup();
    void pmbMIDI();

//  void MIDI_CREATE_DEFAULT_INSTANCE(); //doesn't work

#endif

libMidi.cpp

#include "libMidi.h"
#include <MIDI.h>

void midiSetup(){

//midi::MidiInterface<Type> Name((Type&)SerialPort);

        void MIDI_CREATE_DEFAULT_INSTANCE();
        void MIDI.begin(MIDI_CHANNEL_OMNI);
}

void pmbMIDI(){
    if (MIDI.getType() == 144){
        digitalWrite(13, 1);}

    if (MIDI.getType() == 128){
        digitalWrite(13, 0);}
}

Thank you by advance

chrisl
  • 16,257
  • 2
  • 17
  • 27
Pelosh
  • 47
  • 3
  • You should include the complete error message. Every error has a line number, where it happened. And please show us your complete code, including the Arduino sketch, that is using your library, so that we also can test. – chrisl Oct 29 '19 at 15:02

1 Answers1

0
void MIDI_CREATE_DEFAULT_INSTANCE();

This line should not be placed inside a function, because it is a forward function declaration.

However, I think there are more problems in your code.

My wild guess is to improve the following lines:

  • Uncomment line that doesn't work

Change

MIDI_CREATE_DEFAULT_INSTANCE();

to

MIDI_CREATE_DEFAULT_INSTANCE();

and place it outside a function.

Remove the word void in the following lines

void midiSetup();
void pmbMIDI();

And also align the { and }

void MIDI.begin(MIDI_CHANNEL_OMNI);

So it's a function call.

Other improvements is to remove spaces or tabs in

    void midiSetup();
    void pmbMIDI();

Also align { and } in

if (MIDI.getType() == 144){
    digitalWrite(13, 1);}

if (MIDI.getType() == 128){
    digitalWrite(13, 0);}
Michel Keijzers
  • 12,954
  • 7
  • 40
  • 56