MIDI stream - LinkedList? XML DB? Variable struct with ordering?

Status
Not open for further replies.

Pensive

Well-known member
Hi all,

in building my beatmaker I have fully designed (but not developed) a sequencer solution which was supposed to be more efficient than midi - but by the time i got to the end it became clear that it wasn't really much more efficient, and was probably not the best idea.

SO - back to the drawing board - lets do something industry standard.

I'm going to store raw MIDI data in some kind of data repository in ram.

Its a list of events. Each event features a Delta Time for the event (variable length value), relative to the last event, plus one midi packet of 3 bytes.
So each packet will vary in size according to how recently the last event occurred. Inserting events might begin to leave "holes" where Delta Times have suddenly reduced, if you know what i mean.

  • I need to plonk midi packets in memory as and when they occur, taking into account the time sinc the last event and how it affects the delat time on the following event.
  • I also need to be able to "query" them in the order they occur for the sake of the CPU.
  • SDcard live storage or Audio board SPI flash is out of the question (in real time at least), so filebased formats like XML are probably a bad idea.

I'm thinking of some kind of indexed/linked list of simple MIDI union-ed objects, but does anyone have a hint on a superior way of referencing and manipulating this information?

Cheers

J
 
Last edited:
If your data nodes are a variable size then a linked list, or doubly linked list, lets you access them sequentially (forwards, or forwards and backwards for doubly linked). An array of pointers lets you access them sequentially or randomly.

If your data nodes are a fixed size then you can put them in an array (unless you need random-access insertion).

If the variability in node size is less than the size of one or two pointers then it may be better to make the nodes fixed size, the increase in node size being counterbalanced by needing less/no pointers.

If storage order is the same as arrival order is the same as access order, then an array of fixed size nodes is straightforward. Its not clear to me why delta time needs to be variable length (presumably you are storing it as a digital number not as a string).
 
It's not entirely clear to me either, why delta time needs to be variable length, probably because midi can support up to 24 hours but this would be a big waste of space to store a value sufficient for covering 24 hours to the granularity that MIDI demands.

I'll find a practical size and stick with that.


SHEESH. Been looking at a bunch of open source MIDI libraries. Beginning to wonder if the Teensy is going to be up to this, RAM wise. CPU is fine, but 64k of RAM?

The first ever Atari 520ST, released in 1985:
_______________________________________________________________________________
CPU: Motorola 68000 16-/32-Bit CPU[50] @ 8 MHz. 16 bit data/32 bit internal/24-bit address.
RAM: 512 kB or 1 MB
_______________________________________________________________________________

Teensy smashes it to bits CPU-wise but ram is a major problem. I'm not sure I'm going to succeed, even if i do start ringfencing sketch RAM and poke my midi stuff there.

I think i'll start off with a little step sequencer, build on that and see how it goes. Perhaps I can save into MIDI file formats and take it from there.
 
Status
Not open for further replies.
Back
Top