Record sound in .wav format with Arduino MKR zero

Probably too late to be of help, but maybe this will help someone else who stumbles onto this thread.

I suspect the problem in your code might be that the data comes back from the device as big-endian (suggested by the fact that buffer[4] is always zero while buffer[5-7] contain actual data), while WAV files using "RIFF" should be encoded using little-endian. I would try reordering the bytes for the data you write out just like you reorder the bytes when writing out the header fields.

I expect that this kind of error would create a file that just sounds like a buzzy noise as you experienced.

1 Like