Using the Midi library and writing differences

Am looking and doing some research in sketches and find a couple of differences i dont understand:

Some are written with Serial.Begin and using the Serial.write method

others are Midi.begin with their functions.

is there a difference ? And which should i use ? I asume the midi connection is in both the TX pin

regards Ian

if you use a MIDI library (like this one), then you've a class that represent the midi connexion and thus you use the class to handle the communication and you'll have high level functions and capabilities. For example the library I just linked let you send MIDI over USB, Bluetooth, IP and AppleMIDI or has methods such as sendNoteOn() or sendPitchBend()

if you use directly the Serial line then you use the Serial class. it has no knowledge of midi of coure, so you have to handle everything yourself

aa ok thx ...but still need to add Serial.begin in order to send proper midi messages through the Midi classes

it depends which library you have and on which line you communicate.

If the library expects a link that is already open for its transport, then yes, you need to do Serial.begin() or Serial1.begin() or whatever port is required indeed (baud rate would need to be 31250 for MIDI)

In the library I linked previously, you don't need to open it. you call [url=https://github.com/FortySevenEffects/arduino_midi_library/blob/da8ca5e69a63e1cbf2433e070b87e6f09a709b85/src/serialMIDI.h#L115]MIDI_CREATE_DEFAULT_INSTANCE[/url]() at the start of your sketch and that will configure Serial for you in the library that will be activated when you call begin() for the library.

see their Basic_IO.ino example

ianmacleod:
Some are written with Serial.Begin and using the Serial.write method

It's quite possible to write MIDI programs without using any MIDI library. MIDI programs using Serial.writes are usually doing that. But without any links so I can see what it is you're looking at that's just a guess.

Steve

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.