User Tools

Site Tools


midibox_sd_card_sample_player

This is an old revision of the document!


MIDIbox SD Card Polyphonic Sample Player

This is a brief description of a project in progress to play back samples in real time from an SD card to an I2S based DAC on the Midibox. It will play a number of samples simultaneously, mixing the output to the DAC, the number of samples depends upon the performance of the SD card.

Hardware

You will need:

I have currently only tested this on the LPC1769 based MIOS32 Midibox. It should work in theory if compiled for the STM32, but I don't have one to try!

Creating files on SD card

The system currently looks for a file called 'bank.1' on the SD card root. This is a text file, but must have Unix style line feeds (not DOS style) - just use your friendly programmer's file editor to create one (or make it on a Mac :-) ). It will read up to 64 lines from this file, each line mapping a MIDI note, and the format is e.g:

0x39 c_a.raw
0x3a c_bf.raw

where the first number is the MIDI note number in Hex, and after the space is the filename of the sample to play (up to 8.3 characters).

It looks for the samples in the root of the SD card.

The sample format is fixed as: 44.1kHz 16 bit RAW little endian. Quite a mouthful. Basically use Audacity, Soundforge etc to convert whatever samples you have into this format.

Currently you have to provide a note mapping for each note you want to sound, and usually therefore you will need to generate a sample of the right pitch for each note. This is a lot of samples for a full key range, but hey hopefully you only have to do this once!

Other notes

  • The performance of the SD card will alter how well this works. Remembered to only use FAT format? Good.
  • Every 5.8mS, it will read data from the SD card depending on which MIDI notes are on. There's a built in safety net that stops reading more notes after about 4-5mS (otherwise we risk a crash).
  • It is coded to play up to 8 notes polyphony, but depending on the card speed you may get only 5-6 from time to time…
  • If you watch the debug output in MIOS Studio, it reports the samples loaded on initialisation and also if the safety net is kicking in

To do

  • Cache FAT directory in RAM (currently it periodically needs to re-read it)
  • Implement bank switching
  • Perform simple envelope filtering
  • Implement more MIDI functions (currently literally only note on and off right now on channel 1)

Files

  • I'm currently trying to get SVN set up for the source - should be here soon
midibox_sd_card_sample_player.1321084529.txt.gz · Last modified: 2011/11/12 07:55 by leeby5