plus change track recordings. DMA allocates memory to
requesting processes and tries to re-use ‘holes,’ thereby
making best use of limited memory resources.
There are many DMA methods. This design uses a
simple fixed-block memory pool approach. Recorded note
data is divided into blocks of 256 bytes in SRAM. Each
block has a header byte to indicate: if the block is empty; if
it’s the last block in a sequence; or the address of the next
block in the sequence. Note events are stored sequentially
inside a block.
This method is perfect for sequentially recorded
MIDI events, but we must choose the block size carefully.
Ideally, it’s a size that allows bit-shifting to calculate
addresses (being faster); is big enough to ensure time
spent processing block-headers is insignificant; and is small
enough to minimize internal fragmentation.
Internal fragmentation is when a block is only partially
used, and the unused bytes of the block are inaccessible
and wasted. This isn’t ideal but is unavoidable. Reducing
the block size reduces this wastage but increases the effect
of block overheads.
The 23LCV512 SRAM chip can store 2,000+ note
events. The capacity doesn’t equate to duration, in contrast
to recording audio.
The 23LCV1024 is the 23LCV512’s big brother with
double the memory. So, why don’t we use this instead?
The answer is because of addressing and access times. The
23LCV1024 has 24 bits addressing whereas the 23LCV512
has 16 bits. The more memory, the longer the path to the
data. Since memory is accessed, often in our solution we
want to reduce access time. We compromise between
memory size and speed.
Also, we use a simple algorithm to locate a free
memory block. It scans all blocks until a free one is found.
The more memory, the slower this process can be.
Track Pointers — Keep
Things on Track
As this is a recording and playback system, we must
MIDI and the Horror of Stuck Notes
Any keyboard player experienced with MIDI knows
of the dreaded ‘stuck note.’ This is where a note has
been sounded via a ‘note on’ MIDI message but the
corresponding ‘note off’ message has gone AWOL due to
If the instrument being played is one without
natural decay — such as an organ or strings — then the
stuck note will sound indefinitely. In a live performance
scenario, this can be extremely embarrassing and
stressful, with a frantic search for the off switch or ‘all
notes off’ MIDI panic button!
; FIGURE 14. The SRAM memory layout and Dynamic
; FIGURE 15. Track pointers for the current position.
September/October 2018 35