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 (Ogg Recorder | Adafruit VS1053 MP3/AAC/Ogg/MIDI/WAV Codec Breakout Tutorial | Adafruit Learning System) 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.
void Adafruit_VS1053::startRecordWav(boolean mic)
{
softReset();
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);
}
else
{
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.