fatfs stream writer split file by time or file length

ducls2019
Posts: 3
Joined: Tue Jan 08, 2019 12:35 pm

fatfs stream writer split file by time or file length

Postby ducls2019 » Tue Jan 08, 2019 4:36 pm

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?

ducls2019
Posts: 3
Joined: Tue Jan 08, 2019 12:35 pm

Re: fatfs stream writer split file by time or file length

Postby ducls2019 » Tue Jan 08, 2019 11:27 pm

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 38 guests