Hi @TE-KarlKomierowski, below is the recorder sketch I was using. I am using an SD Card. It's a SanDisk 64GB Ultra microSDXC
#include <SDHCI.h>
#include <Audio.h>
SDClass theSD;
AudioClass *theAudio;
File myFile;
bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
*/
static void audio_attention_cb(const ErrorAttentionParam *atprm)
{
puts("Attention!");
if (atprm->error_code >= AS_ATTENTION_CODE_WARNING)
{
ErrEnd = true;
}
}
/**
* @brief Setup recording of mp3 stream to file
*
* Select input device as microphone <br>
* Initialize filetype to stereo mp3 with 48 Kb/s sampling rate <br>
* Open "Sound.mp3" file in write mode
*/
static const int32_t recoding_frames = 400;
static const int32_t recoding_size = recoding_frames*288; /* 96kbps, 1152sample */
void setup()
{
theAudio = AudioClass::getInstance();
theAudio->begin(audio_attention_cb);
puts("initialization Audio Library");
/* Select input device as microphone */
theAudio->setRecorderMode(AS_SETRECDR_STS_INPUTDEVICE_MIC, AS_MICGAIN_HOLD, 68, true);
/*
* Initialize filetype to stereo mp3 with 48 Kb/s sampling rate
* Search for MP3 codec in "/mnt/sd0/BIN" directory
*/
theAudio->initRecorder(AS_CODECTYPE_MP3, "/mnt/sd0/BIN", AS_SAMPLINGRATE_48000, AS_CHANNEL_STEREO);
puts("Init Recorder!");
/* Open file for data write on SD card */
myFile = theSD.open("Sound.mp3", FILE_WRITE);
/* Verify file open */
if (!myFile)
{
printf("File open error\n");
exit(1);
}
theAudio->startRecorder();
puts("Recording Start!");
}
/**
* @brief Record given frame number
*/
void loop()
{
err_t err;
/* recording end condition */
if (theAudio->getRecordingSize() > recoding_size)
{
theAudio->stopRecorder();
sleep(1);
err = theAudio->readFrames(myFile);
goto exitRecording;
}
/* Read frames to record in file */
err = theAudio->readFrames(myFile);
if (err != AUDIOLIB_ECODE_OK)
{
printf("File End! =%d\n",err);
theAudio->stopRecorder();
goto exitRecording;
}
if (ErrEnd)
{
printf("Error End\n");
theAudio->stopRecorder();
goto exitRecording;
}
/* This sleep is adjusted by the time to write the audio stream file.
Please adjust in according with the processing contents
being processed at the same time by Application.
*/
// usleep(10000);
return;
exitRecording:
theAudio->closeOutputFile(myFile);
myFile.close();
theAudio->setReadyMode();
theAudio->end();
puts("End Recording");
exit(1);
}