Go Down

Topic: Unable to Successfully Record Audio with the VS1053. (Read 3502 times) previous topic - next topic


Apr 26, 2014, 02:40 pm Last Edit: Apr 26, 2014, 02:49 pm by csnate Reason: 1
Hello all, I am working on a research project recording bird songs.  For lack of a better term, I am the resident computer scientist.  We are trying to use an Arduino and the VS1053 to record birds that have been tagged with an RFID chip.  When a tagged bird comes close enough to our antenna for a read, we want to begin recording.

The RFID reader works, but the audio recording does not.  We've used code from OGG recording sketch (https://learn.adafruit.com/adafruit-vs1053-mp3-aac-ogg-midi-wav-play-and-record-codec-tutorial/ogg-recorder) but have been unsuccessful.  We then tried to use WAV recording using mods from a guy named 'jonlab' over on the Adadfruit forums to record wave files and have also been unsuccessful with that method.

I've posted a link to the code, I'm hoping we could get some help on this.  I would have posted the code directly, but its too long.


The code added to the VS1053 library.

Code: [Select]
void Adafruit_VS1053::startRecordWav(boolean mic)
   while (! readyForData() );
   sciWrite(VS1053_SCI_AICTRL0, 16000);    //Sample rate between 8000 and 48000
   sciWrite(VS1053_SCI_AICTRL1, 0);        //Recording gain : 1024 : 1.If 0, use AGC
   sciWrite(VS1053_SCI_AICTRL2, 4096);     //Maximum AGC level: 1024 = 1. Only used if SCI_AICTRL1 is set to 0.
   //Miscellaneous bits that also must be set before recording.
   sciWrite(VS1053_SCI_AICTRL3, 0); //joint stereo AGC + IMA ADPCM
   //sciWrite(VS1053_SCI_AICTRL3, 2); //LEFT only
   //sciWrite(VS1053_SCI_AICTRL3, 3); //RIGHT only
   //sciWrite(VS1053_SCI_AICTRL3, 4); //joint stereo AGC + LINEAR PCM
   if (mic)
       sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_RESET | VS1053_MODE_SM_ADPCM | VS1053_MODE_SM_SDINEW);
       sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_RESET | VS1053_MODE_SM_LINE1 | VS1053_MODE_SM_ADPCM | VS1053_MODE_SM_SDINEW);
   while (! readyForData() ); //!!!!!!!!!!!!
   //IMA fix patch
   sciWrite(VS1053_REG_WRAMADDR, 0x8010);
   sciWrite(VS1053_REG_WRAM, 0x3e12);
   sciWrite(VS1053_REG_WRAM, 0xb817);
   sciWrite(VS1053_REG_WRAM, 0x3e14);
   sciWrite(VS1053_REG_WRAM, 0xf812);
   sciWrite(VS1053_REG_WRAM, 0x3e01);
   sciWrite(VS1053_REG_WRAM, 0xb811);
   sciWrite(VS1053_REG_WRAM, 0x0007);
   sciWrite(VS1053_REG_WRAM, 0x9717);
   sciWrite(VS1053_REG_WRAM, 0x0020);
   sciWrite(VS1053_REG_WRAM, 0xffd2);
   sciWrite(VS1053_REG_WRAM, 0x0030);
   sciWrite(VS1053_REG_WRAM, 0x11d1);
   sciWrite(VS1053_REG_WRAM, 0x3111);
   sciWrite(VS1053_REG_WRAM, 0x8024);
   sciWrite(VS1053_REG_WRAM, 0x3704);
   sciWrite(VS1053_REG_WRAM, 0xc024);
   sciWrite(VS1053_REG_WRAM, 0x3b81);
   sciWrite(VS1053_REG_WRAM, 0x8024);
   sciWrite(VS1053_REG_WRAM, 0x3101);
   sciWrite(VS1053_REG_WRAM, 0x8024);
   sciWrite(VS1053_REG_WRAM, 0x3b81);
   sciWrite(VS1053_REG_WRAM, 0x8024);
   sciWrite(VS1053_REG_WRAM, 0x3f04);
   sciWrite(VS1053_REG_WRAM, 0xc024);
   sciWrite(VS1053_REG_WRAM, 0x2808);
   sciWrite(VS1053_REG_WRAM, 0x4800);
   sciWrite(VS1053_REG_WRAM, 0x36f1);
   sciWrite(VS1053_REG_WRAM, 0x9811);
   sciWrite(VS1053_REG_WRAMADDR, 0x8028);
   sciWrite(VS1053_REG_WRAM, 0x2a00);
   sciWrite(VS1053_REG_WRAM, 0x040e);

void Adafruit_VS1053::stopRecordWav(void) {
   sciWrite(VS1053_SCI_AICTRL3, 1);

The relevant bits are located in the loop and the writeRecordedData functions.  Any help is appreciated!

Edit: Specifically, we are able to create .WAV files on the SD card but they are always either 0 or 1 kb large and the 1kb files are reported as corrupt.


It's not perfect. But this guy has the begining of an answer, check it out.

Record voice by vs1053

Happy new year!
As we fight our way northward into the great unknown, only that one thing remains certain...

Go Up