Forums > MaxMSP

sending a .wav file using serial


azs
May 26, 2009 | 4:30 pm

I would like to build an interface in max that allows a person to record and write a .wav file to an sd card using an arduino microcontroller. I know how to record and save .wav files. I also know how to send data over serial to arduino. I have no idea how to read the .wav as data, not as a signal, to be sent over serial.


May 26, 2009 | 5:46 pm

azs wrote on Tue, 26 May 2009 11:30I would like to build an interface in max that allows a person to record and write a .wav file to an sd card using an arduino microcontroller. I know how to record and save .wav files. I also know how to send data over serial to arduino. I have no idea how to read the .wav as data, not as a signal, to be sent over serial.

The short answer is peek~, but there’s a bit more to it.

You can treat a .wav file as floating-point data by reading it into a buffer~, then using uzi –> peek~ to get each sample, for the total # of samples. These would then be converted to 16-bit integer values using [scale -1. 1. 0 65535], then broken into 8-bit values (using / 256 and % 256) and sent over the serial as pairs of bytes, with a start and stop code for the data point. Or you could probably work out a way to send more compact lists of your points, without needing all the start/stop codes.

See if something like this helps. Again, there are probably better ways to do this, and I haven’t tested this one, but you should be able to write the Arduino code to work with this. BTW how does it write to the SD card—one point at a time, or in chunks? This patch sends them one at a time.

– Pasted Max Patch, click to expand. –


azs
May 26, 2009 | 8:27 pm

BTW how does it write to the SD card—one point at a time, or in chunks? This patch sends them one at a time.

At this point, I am just looking into feasibility, but I’m not sure how everything works. I am planning to use the SD_uFAT Basic library for writing, and ladyada’s wave sheild and the associated library to playback wave files.


Viewing 3 posts - 1 through 3 (of 3 total)