IMP Audio Streaming

Apart from the lala, is there a simple SPI component one can use with the same code? I don’t need recording, just play. And I would like to get away with minimum space.

The SPI component on lala is pretty simple - just a SPI flash hooked to the imp’s SPI pins. They can be tiny, too…

Okay, is there an easy SPI module one can get from sparkfun or so? I dont have the capacity to get an SPI and the right resistors, etc. that it takes to connect an SPI. Basically I am just wiring up components, cant design my own breakouts.

Is it something like this?
Does that exist as a breakout? Is this one?
Hoe much storage do I need to run the Lala code on my setup?

You can actually get away with playing audio back from the imp without needing local storage, depending on your application. We chose to include the SPI flash on Lala because it gives you the chance to asynchronously receive and playback messages. If you just want to push messages to the imp and play them back, you can just chunk them right down from the agent and load them into the fixed frequency DAC without bothering to save them to flash at all.

If you’re looking for the memory specifically, it’s actually not too terribly hard to put the SPI flash from Lala down on a surfboard ( and slap that into a breadboard or solder lines to the surboard.

The part you’ve got there in the sparkfun link is actually a SPI EEPROM, not a SPI flash; I expect you’d have to do some editing with the code to get that working as the commands are not going to be the same. The SPI flash on the Lala design is available from sparkfun, and you can get it in smaller capacities from there, too, which is cheaper.

Cool I hoped i could turn the imp into a simple interface for the data.

how much do I need to change the lala code to get straight streaming play?

I have .wav files that i would like to use this technic with is there same sample code that i could follow the bypassing of the SPI Flash and chunking into the fixed frequency DAC? It seems like a very useful technic.

Is there an example of chunking them down from the agent and loading them into the fixed frequency DAC without bothering to save them to flash.

I have done this, although we don’t have a well-polished example. Try something along these lines. This code assumes that you have an A-Law compressed wav at 8Khz. On the agent-side, suppose that writeBuffer() is a function which returns the next chunk of a wav file.

function startDAC()
configuration <- {
buffers = [writeBuffer(), writeBuffer(), writeBuffer()]
sampleRateHz = 8000
pin1 = true
decompress = true
device.send(“start”, configuration);

device.on(“more_data_please”, function(nbuffers) {
local buffer = writeBuffer();
if (buffer != 0) {
device.send(“more_data”, buffer);


On the imp

agent.on(“start”, function(configuration) {
local pin = configuration.pin1 ? hardware.pin1 : hardware.pin5;
local options = configuration.decompress ? A_LAW_DECOMPRESS : 0;
hardware.fixedfrequencydac.configure(pin, configuration.sampleRateHz, configuration.buffers, bufferEmpty, options);

agent.on(“stop_fixed_frequency_dac”, function(msg) {

agent.on(“more_data”, function(buffer) {

function bufferEmpty(buffer)
if (!buffer) {
agent.send(“more_data_please”, 1);


So in essence, the agent initiates the playback. Whenever the fixed frequency DAC has consumed a buffer it sends a request to the agent for another. What this simple code hides is parsing the WAV in the agent, and also working out when the playback is finished. I emphasise that this is just indicative, rather than a complete solution, but hopefully it can set you off on the right lines.