[sdiy] MIDI spec

Colin f colin at colinfraser.com
Wed Dec 4 11:31:47 CET 2002


----- Original Message -----
From: "Paul Maddox" <P.Maddox at signal.qinetiq.com>
To: <synth-diy at dropmix.xs4all.nl>
Sent: Wednesday, December 04, 2002 9:03 AM
Subject: Re: [sdiy] MIDI spec


> > (2) In the main loop, I pole the buffer and process messages as they
> become available.  This way processing can take a long time if necessary
> (for example if many calculations are required to use the message), and it
> doesn't block the time critical timer-driven interrupts such as the
software
> LFOs, Envelopes and Portamento, and the S&H refreshing/sequencing.
> >
>
> yep, I do this with the AVR, once a byte is received via the UART IRQ, I
> dump into a buffer.
> In the main loop I check to see if the buffer pointer is greater than 0,
> then jump to it and read the buffer..
> It gets checked about 100,000 times a second..

I'm going about things in a slightly different way in my current convertor
project (which is taking ages, but anyway...)
Given that midi bytes are separated by at least 0.32 ms, I don't believe you
need a buffer any bigger than 3 bytes for all but system exclusive messages.
If you can't process a 3 byte message in ~ 0.1 ms, your CPU is too slow
(unless you're doing something really complex like polyphonic voice
assignment, but even then, I'd still argue that if you're polling in a loop
for time critical events like the arrival of a midi message, you system is
not sufficiently real-time).
In practice, it's not even a buffer - it's a running status register, two
data byte registers, and flags to indicate whether the system is waiting for
a new status byte, the first data byte, or the second data byte.
So basically, I'm processing the arriving midi messages in the serial
interrupt routine itself (once they are complete), and updating state tables
for the cv/gate outputs.
I put the S&H refresh code into the main loop. It doesn't need the rock
solid regularity of a timer event, and IMO it's more important to be acting
on received messages than it is to be updating caps.
If you want to add timer interrupts for EGs, LFOs etc, the routine would
need to take less time than the length of one midi byte, to prevent the
serial IRQ routine potentially missing a byte, but again, if this is not the
case, your CPU is not fast enough to do the job in real-time.
All just IMHO, of course...

Colin f



More information about the Synth-diy mailing list