Hi,
I'm new to esp32. I bought an ESP32-LyraT kit and tried some example in ADF. Now I need your suggestion:
I recorded voice over Audio Codec chip and save it to multiple file on SD Card. Could u help me do right to split audio stream to multiple files by time or length?
fatfs stream writer split file by time or file length
Re: fatfs stream writer split file by time or file length
Here is my short code that I modified from sample. It's will be error "cannot rename file"
Code: Select all
while (1) {
audio_event_iface_msg_t msg;
if (audio_event_iface_listen(evt, &msg, 1000 / portTICK_RATE_MS) != ESP_OK) {
second_recorded++;
ESP_LOGI(tag, "[ * ] Recording ... %d", second_recorded);
if (second_recorded >= RECORD_TIME_SECONDS) {
ESP_LOGI(tag, "Finishing amr recording");
char filenameFinal[255];
sprintf(filenameFinal, "%s.%s", filenameTmp, "amr");
if(0 == renameFile(filenameTmp,filenameFinal)){
ESP_LOGI(tag, "Done record to file [%s]", filenameFinal);
}else{
ESP_LOGE(tag, "Record to file [%s] fail!", filenameFinal);
}
ESP_LOGI(tag, "Continue setup uri (file as fatfs_stream, amr as amr encoder)");
//setup filename
time_t nowi = time(NULL);
timenow = localtime(&nowi);
strftime(filenameTmp, sizeof(filenameTmp), "/sdcard/voice_%Y_%m_%d_%H_%M_%S", timenow);
int exists = check_file(filenameTmp);
if (exists == 1) {
ESP_LOGI(tag, "File name was existed! -> append");
}
ESP_LOGI(tag,"record to temp file [%s]",filenameTmp);
audio_element_set_uri(fatfs_stream_writer, filenameTmp);
// break;
//not break anymore
second_recorded = 0;
}
continue;
}
Who is online
Users browsing this forum: No registered users and 20 guests