Lo-Fi Orchestra – Fanfare for the Common Man

Here is another piece for my Arduino tones- Aaron Copland’s Fanfare for the Common Man.  This is scored for four horns, three trumpets, three trombones, tuba, timpani, bass drum and tam-tam.

The Arduino tones provide the brass.  The VS1053 provides the timpani and bass drum, but the tam-tam was a bit problematic.  Eventually I decided to find a sampled tam-tam and squeeze it into an Arduino with an MCP4725 DAC.  Read on below to find out how!

I have a great sounding tam-tam thanks to a complete set of orchestral samples I’d downloaded before (but unfortunately don’t have the details of where they came from any more!).  However, a full 44kHz, CD-quality, 8-second long tam-tam is really not going to fit into an Arduino – the WAV file itself is over 71KB in size and the Arduino only has 32KB of flash in total for all its code and constant data, including the bootloader.

So I followed the procedure I used with the MCP4725 before to generate an 8192Hz sample rate, 8-bit mono PCM data stream and covert it to code.  The previous system used a 16-bit sample and scaled it down to fit the required 12-bits of the MCP4725.  I tried this, but had to limit the sample to around 1.5 seconds to make it fit and it sounded pretty terrible, so instead I resampled the audio to 8-bits and scaled it up slightly to 10-bits in the code.  This allowed for around 3 seconds of tam-tam, which was ok.

This required replacing the following line:

dacWrite(pgm_read_word(&(wtdata[i])) >> SAMPLE_SCALING);

with this one:

 dacWrite(((uint16_t)pgm_read_byte(&(wtdata[i]))) << 2);

The result isn’t brilliant, but it isn’t bad for an 8-bit resolution sample player coming from an 8-bit microcontroller with 32KB of memory!

To trigger it, the code is listening on MIDI channel 10 for note number 52.  The other percussion (bass drum and timpani) is provided by the VS1053 as described before.

All music rights and copyright with original authors, composers, producers, artists, and so on.

Kevin

Leave a comment