<div dir="ltr">I think the biggest drawback of usb is that you can connect only one device to each port. 5 DIN midi can be buffered and spread around the studio to 16 instruments, and there is no additional overhead for your master computer in doing so. If you dare connect 16 USB MIDI devices...yeah, that would be ugly.<div>MIDI specifies how real time messages are interleaved with the rest, and there's some care required when making the state machine in order to fully comply with the last version. AFAIK arduino MIDI.h handles that properly, even without using the interrupts. </div><div><br></div><div>After writing the above, I decided to have a deeper look into the teensy 3.2 interrupts. Turns out you can hack an ISR in the teensyduino core. Here's my fix:</div><div>usb_isr is the interrupt routine for USB, and is defined under teensy3>usb_dev.c. In there you will notice a few #ifdef statements, for the various USB device modes. We will create a function pointer, that is called by the teensy usb_isr, and expose it to our arduino main.cpp so we can attach whatever we need to it.<br></div><div>1. in teensy3>usb_dev.h add:</div><div>            void (*usbMIDI_isr)(void);<br>            void usbMIDI_attach_interrupt(void (*fptr)());</div><div>2. in teensy3>usb_dev.c find usb_isr and add above it:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>        void usbMIDI_attach_interrupt(void (*fptr)())</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>{</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>    usbMIDI_isr = fptr;</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">}<br></blockquote></blockquote>3.right before the end of usb_isr() add:<div>           if (usbMIDI_isr)<br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>    {</div><div>        (*usbMIDI_isr)();</div><div>    } </div></blockquote>4. in kinetis.h locate the list of _isr functions, around line 5800. At the end of the list, add:<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>extern void usbMIDI_attach_interrupt(void (*fptr)());</div></blockquote><br><div>in my main scetch I just call usbMIDI_attach_interrupt(&readMIDI);, and run the MIDI.h read code without any changes. It seems to work.</div><div><br></div><div>There is some overhead in the MIDI library that by the looks of it would be manageable. It could do with some optimization, but I wouldn't worry too much about it, for now.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 20 Dec 2021 at 21:26, mars <<a href="mailto:mars@pingdynasty.com">mars@pingdynasty.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto">Well in USB MIDI everything is packaged into 4 byte packets so you don't get interspersed clocks. Or running status.</div><div dir="auto"><br></div><div dir="auto">Martin</div><div dir="auto"><br></div><div><br></div><div align="left" dir="auto" style="font-size:100%;color:rgb(0,0,0)"><div>-------- Original message --------</div><div>From: MTG <<a href="mailto:grant@musictechnologiesgroup.com" target="_blank">grant@musictechnologiesgroup.com</a>> </div><div>Date: 20/12/2021  18:34  (GMT+01:00) </div><div>To: <a href="mailto:synth-diy@synth-diy.org" target="_blank">synth-diy@synth-diy.org</a> </div><div>Subject: Re: [sdiy] Techniques for Multiplying MIDI Clock frequency? </div><div><br></div></div>USB-MIDI is another layer (of hell). I don't think it's going to solve <br>any issues that 5-pin DIN has. Maybe because the microcontrollers that <br>have USB are typically many, many times faster than an old 8-bit one <br>though. OTOH, some USB stacks are very poorly written.<br><br><br>On 12/20/2021 8:55 AM, Benjamin Tremblay via Synth-diy wrote:<br>> I finally bought a mini scope. I have no excuse not to use it.<br>> I agree, this is not a hard limitation on 5 pin MIDI, but it’s too easy <br>> for developers interested in performance to abandon it and move to USB.<br>> <br>_______________________________________________<br>Synth-diy mailing list<br><a href="mailto:Synth-diy@synth-diy.org" target="_blank">Synth-diy@synth-diy.org</a><br><a href="http://synth-diy.org/mailman/listinfo/synth-diy" target="_blank">http://synth-diy.org/mailman/listinfo/synth-diy</a><br>Selling or trading? Use <a href="mailto:marketplace@synth-diy.org" target="_blank">marketplace@synth-diy.org</a><br></div>_______________________________________________<br>
Synth-diy mailing list<br>
<a href="mailto:Synth-diy@synth-diy.org" target="_blank">Synth-diy@synth-diy.org</a><br>
<a href="http://synth-diy.org/mailman/listinfo/synth-diy" rel="noreferrer" target="_blank">http://synth-diy.org/mailman/listinfo/synth-diy</a><br>
Selling or trading? Use <a href="mailto:marketplace@synth-diy.org" target="_blank">marketplace@synth-diy.org</a><br>
</blockquote></div>