[sdiy] MIDI Clock sync advice
René Schmitz
synth at schmitzbits.de
Fri Mar 15 13:57:42 CET 2024
On 15.03.2024 09:29, Spiros Makris via Synth-diy wrote:
> Roman Sowa wrote:
> > And it's pretty easy to do, as MIDI clock message has no dependencies at
> > all, it can even go between bytes of single note message. Just look for
> > F8 in UART register and bam!
> >
> > I'm a bit surprised that such powerfull processors as used in arduinos
> > can't handle increased traffic, while everything needed to be done in
> > any MIDI receiver can be easily handled within one byte transmission,
> > that is 0.3ms. OTOH I don't use arduinos or libraries so what do I know.
The speed of processors roughly keeps up with programmers ability to
waste it.
>
> While I'm a big supporter of frameworks like arduino, many libraries
> tend to be extremely inefficient. MIDI implementations are a prime
> example; most I've found floating around work with polling rather than
> interrupts.
I tend to agree with respect to arduino and libraries. I've used AVR
long before arduino even became a thing, and found it rather limiting in
the beginning.
My gripe is that, for beginner programmer, it does not necessarily teach
good practices, and even for a seasoned one it proliferates some bad
habits. (How often is everything in loop()...)
It's like giveing you a nice sugar coated piece of cake, so you might
never be motivated to learn how to bake a better one.
Back to MIDI: generally, when using the serial interrupt you have two
choices:
Either make the ISR short, and for example just throw the data into a
buffer.
Or do all the processing (which could take some time) there. Risk is
that you might block other ISRs, such as timers, which is of course bad.
In the former case you still have to poll the queue at some regular
short interval to do the processing.
You should probably do the clock related timekeeping, processing right
in the ISR.
So I can see how the authors of a library end up saying: I don't care.
Let's poll the whole thing, and not bother with the interrupt.
Especially since there would otherwise be inevitable resource clashes
with other libraries which would drive users mad. (How servo libs grab
the various timers for example.)
What the arduino framework would need, is a mechanism to manage call
backs on the various interrupts.
Best,
René
--
synth at schmitzbits.de
http://schmitzbits.de
More information about the Synth-diy
mailing list