<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";
mso-fareast-language:EN-GB;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">There should be no problem with connecting lots of USB instruments provided you use a good USB hub. Main problem is some software stacks don’t implement plug
and play properly which makes things a PITA.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Synth-diy [mailto:synth-diy-bounces@synth-diy.org]
<b>On Behalf Of </b>Spiros Makris via Synth-diy<br>
<b>Sent:</b> 21 December 2021 07:38<br>
<b>To:</b> mars<br>
<b>Cc:</b> synth-diy mailing list<br>
<b>Subject:</b> Re: [sdiy] Techniques for Multiplying MIDI Clock frequency?<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1. in teensy3>usb_dev.h add:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> void (*usbMIDI_isr)(void);<br>
void usbMIDI_attach_interrupt(void (*fptr)());<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">2. in teensy3>usb_dev.c find usb_isr and add above it:<o:p></o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<p class="MsoNormal"> void usbMIDI_attach_interrupt(void (*fptr)())<o:p></o:p></p>
</div>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<p class="MsoNormal">{<o:p></o:p></p>
</div>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<p class="MsoNormal"> usbMIDI_isr = fptr;<o:p></o:p></p>
</div>
</blockquote>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<p class="MsoNormal">}<o:p></o:p></p>
</blockquote>
</blockquote>
<p class="MsoNormal">3.right before the end of usb_isr() add:<o:p></o:p></p>
<div>
<p class="MsoNormal"> if (usbMIDI_isr)<o:p></o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<p class="MsoNormal"> {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> (*usbMIDI_isr)();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> } <o:p></o:p></p>
</div>
</blockquote>
<p class="MsoNormal">4. in kinetis.h locate the list of _isr functions, around line 5800. At the end of the list, add:<o:p></o:p></p>
<div>
<p class="MsoNormal">extern void usbMIDI_attach_interrupt(void (*fptr)());<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, 20 Dec 2021 at 21:26, mars <<a href="mailto:mars@pingdynasty.com">mars@pingdynasty.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Well in USB MIDI everything is packaged into 4 byte packets so you don't get interspersed clocks. Or running status.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Martin<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">-------- Original message --------<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">From: MTG <<a href="mailto:grant@musictechnologiesgroup.com" target="_blank">grant@musictechnologiesgroup.com</a>>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Date: 20/12/2021 18:34 (GMT+01:00)
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">To: <a href="mailto:synth-diy@synth-diy.org" target="_blank">
synth-diy@synth-diy.org</a> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Subject: Re: [sdiy] Techniques for Multiplying MIDI Clock frequency?
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal">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><o:p></o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<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><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>