This is a brief description of a project 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.
You will need:
It has now been run on both LPC1769 and STM32 cores…
As of rev 1371 on the SVN, it now reads a file called 'player.cfg' from the SD card which is a UNIX style file (there's an example in the SVN) which contains name value pair separated by a space. At present it only supports two parameters, eg:
midichannel 1 lee_hw 1
The first one (obviously) sets the midi channel for the player. The second value is to enable my simple rotary bank switch on J10 (you probably want this set to zero if you have a real midibox core, and want to use MIDI program change to select the bank).
The system currently looks for a file called 'bank.1' on the SD card root by default (and bank.2, bank.3 etc as you send a program change). 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 0 0031 c_a.raw 0x3a 1 0000 c_bf.raw
where the first number is the MIDI note number in Hex, the single digit is 0=no sample hold, 1=sample hold (ie for drums etc), the 4 digit number is a decimal value for an envelope decay (0000=no decay, and up to 1023 is supported) 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: monophonic (1 channel) 44.1kHz 16 bit RAW signed 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!