Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial Midi with custom BaudRate and Library version 5 #215

Open
ClaudioCas opened this issue Apr 18, 2021 · 7 comments
Open

Serial Midi with custom BaudRate and Library version 5 #215

ClaudioCas opened this issue Apr 18, 2021 · 7 comments

Comments

@ClaudioCas
Copy link

Dear all,

I'm using the following code for initialize my Midi over Usb Serial with custom boudrate according with this doumentation (https://github.com/FortySevenEffects/arduino_midi_library/wiki/Using-custom-Settings) to use Arduino Mega and Hairless MIDI.


  #include <MIDI.h>
  struct CustomBaudRate : public midi::DefaultSettings{

      static const long BaudRate = 19200;

  };
  MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);

It works great with versione 4.3.1.

I upgrade the library to version 5.0.2 for use native HID with Leonardo. The Usb Midi Native version works relly well, but now if I try to compile the old code (for Usb Serial) with new library I had the following errors:

In file included from C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/MIDI.h:35:0,
                 from c:\Users\ClaudioCas\Documents\Arduino\MidiProject\MidiProject.ino:27:
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:122:71: error: no matching function for call to 'midi::SerialMIDI<HardwareSerial, CustomBaudRate>::SerialMIDI(Serial_&)'
     MIDI_NAMESPACE::SerialMIDI<Type, Settings> serial##Name(SerialPort);\
                                                                       ^
c:\Users\ClaudioCas\Documents\Arduino\MidiProject\MidiProject.ino:36:3: note: in expansion of macro 'MIDI_CREATE_CUSTOM_INSTANCE'
   MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:48:2: note: candidate: midi::SerialMIDI<SerialPort, _Settings>::SerialMIDI(SerialPort&) [with SerialPort = HardwareSerial; _Settings = CustomBaudRate]
  SerialMIDI(SerialPort& inSerial)
  ^~~~~~~~~~
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:48:2: note:   no known conversion for argument 1 from 'Serial_' to 'HardwareSerial&'
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:43:7: note: candidate: constexpr midi::SerialMIDI<HardwareSerial, CustomBaudRate>::SerialMIDI(const midi::SerialMIDI<HardwareSerial, CustomBaudRate>&)
 class SerialMIDI
       ^~~~~~~~~~
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:43:7: note:   no known conversion for argument 1 from 'Serial_' to 'const midi::SerialMIDI<HardwareSerial, CustomBaudRate>&'
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:43:7: note: candidate: constexpr midi::SerialMIDI<HardwareSerial, CustomBaudRate>::SerialMIDI(midi::SerialMIDI<HardwareSerial, CustomBaudRate>&&)
C:\Users\ClaudioCas\Documents\Arduino\libraries\MIDI_Library\src/serialMIDI.h:43:7: note:   no known conversion for argument 1 from 'Serial_' to 'midi::SerialMIDI<HardwareSerial, CustomBaudRate>&&'
Compilation error: Error: 2 UNKNOWN: exit status 1

I'm using Arduino IDE 2.0.0 beta 5

Thanks a lot
Claudio

@ClaudioCas ClaudioCas added the bug label Apr 18, 2021
@franky47
Copy link
Member

I cannot reproduce your error, your example code compiles fine on both Arduino IDE 1.8 and 2.0.

@ClaudioCas
Copy link
Author

ClaudioCas commented Apr 18, 2021

Dear Franky,
first of all, thanks a lot for your kind and quick reply.
immagine

This is a empty sketch and doesn't copile for me. I double check, I have 5.0.2 Midi Library


  #include <MIDI.h>

  //Arduno Mega + Hairless Midi = 19200;
  struct CustomBaudRate : public midi::DefaultSettings{

      static const long BaudRate = 19200;

  };
  MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

@lathoub
Copy link
Collaborator

lathoub commented May 13, 2021

Leonardo uses Serial1, not Serial in the above example.
Change to:
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, CustomBaudRate);

See also:

#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
// Leonardo, Due and other USB boards use Serial1 by default.
#define MIDI_CREATE_DEFAULT_INSTANCE() \
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
#else

and
#65

@lathoub lathoub removed the bug label May 13, 2021
@steeley
Copy link

steeley commented Apr 2, 2022

I have the same issue. Custom settings does not work at all. I tried the example above for Leonardo and still get the error:
MIDI_Library/src/serialMIDI.h:62:13: error: 'BaudRate' is not a member of 'midi::SerialMIDI<HardwareSerial, MySettings>::Settings {aka MySettings}' mSerial.begin(Settings::BaudRate); ^~~~~~~ exit status 1 Error compiling for board Arduino Leonardo.

@copych
Copy link

copych commented Mar 9, 2024

MIDI Library ver.5.0.2
ESP core 2.0.14
target: ESP32S3 (LOLIN S3 Pro)
I can compile in Arduino IDE 1.8.20 , but cannot in Arduino IDE 2.3.1
target: ESP32S3 (LOLIN S3 Pro)
the errors start with

error: no matching function for call to 'midi::SerialMIDI<HardwareSerial, CustomBaudRateSettings>::SerialMIDI(HWCDC&)'
 MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);

@lathoub
Copy link
Collaborator

lathoub commented Mar 11, 2024

When using the custom settings, make sure you use either a clone or copy from this repo, not a Release version (eg from the Arduino lib manager).

A new release is upcoming

@01GOD
Copy link

01GOD commented Oct 24, 2024

MIDI Library ver.5.0.2 ESP core 2.0.14 target: ESP32S3 (LOLIN S3 Pro) I can compile in Arduino IDE 1.8.20 , but cannot in Arduino IDE 2.3.1 target: ESP32S3 (LOLIN S3 Pro) the errors start with

error: no matching function for call to 'midi::SerialMIDI<HardwareSerial, CustomBaudRateSettings>::SerialMIDI(HWCDC&)'
 MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);

Saw now while looking for a solution while compiling that acidbox project. Found a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants