Hi Ingo, It's not clear to me which parts of your setup are hardware MIDI and which are hardware serial, so this may be not relevant: MIDI uses the same serial protocol as regular serial, the difference is the baud rate (31250 is not a standard baud rate) At the hardware level, MIDI is optoisolated and works as a current loop. At the Pd end, MIDI messages are handled completely separately from whatever [comport] is doing, so you have to 'manually' reconstruct MIDI from a serial stream (as with [midifile], which also doesn't integrate with Pd's MIDI sytsem, as MIDI is being handled at the driver level, and uses a different software interface).
So if your baud rate on the Arduino is 31250, at the minimum you need [comport] to be running at 31250 s well, which is not usually possible. It's easier to use a MIDI interface on the computer and send MIDI from the arduino directly. This can be done using 2 220 Ohm resistors and a DIN-5 connector.
Martin
On Mon, Mar 22, 2021 at 4:13 AM Ingo ingo@miamiwave.com wrote:
Hi,
I would like to send MIDI with [comport] from Pd by using an Arduino.
Reading into Pd is no problem. It also works fine as a MIDI Thru by simply forwarding the Serial1 RX input (MIDI input) to the Serial1 TX output (MIDI Thru). Something like this:
if (Serial1.available() > 0) { Serial1.write(Serial1.read()); }
(The loop duration is only about 250 盜 so there is no timing problem in this case. For data coming in faster than the loop duration I would probably have to read into an arry first.)
However, if I'm sending a MIDI message from Pd it's not recognized by the connected MIDI interface. I'm assuming that's probably because there is no startbit and stopbit that the MIDI interface is looking for.
According to the helpfile I can send a stopbit with [comport] but I didn't find anything about a startbit.
Is there a possibility within Pd and [comport] to send a startbit or would it make more sense to add the startbit and stopbit within the Arduino programming?
Thanks! Ingo
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list