Skip to content

Commit

Permalink
Audio: Support split recording
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE authored Oct 13, 2022
2 parents f939ad8 + fc3d7da commit 8bfea4d
Show file tree
Hide file tree
Showing 21 changed files with 371 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,8 @@ err_t AudioClass::writeWavHeader(File& myFile)
return AUDIOLIB_ECODE_FILEACCESS_ERROR;
}

m_es_size = 0;

return AUDIOLIB_ECODE_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ err_t MediaRecorder::writeWavHeader(File& myfile)
return MEDIARECORDER_ECODE_FILEACCESS_ERROR;
}

m_es_size = 0;

return MEDIARECORDER_ECODE_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,20 @@ void loop()

theAudio->setBeep(1,-40,theNote.fs);

/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(theNote.time * 1000);

theAudio->setBeep(0,0,0);

/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(100000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ void play_process( AudioClass *theAudio, AudioClass::PlayerId play_id, File& fil
break;
}

/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
/* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(40000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SDClass theSD;
/**
* @brief Audio(player0) attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void attention_player_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -259,10 +259,10 @@ void play_process( MediaPlayer *thePlayer, struct PLAY_ELM_T *elm, File& file)
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(40000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -153,10 +153,10 @@ void loop() {
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

// usleep(10000);
Expand Down Expand Up @@ -190,4 +190,4 @@ exitRecording:
puts("End Recording");
exit(1);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool ErrEnd = false;
/**
* @brief Frontend attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

void frontend_attention_cb(const ErrorAttentionParam *param)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -158,10 +158,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(40000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -162,10 +162,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -246,10 +246,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(40000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -211,10 +211,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -156,10 +156,10 @@ bool playStream()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(40000);
Expand Down Expand Up @@ -237,10 +237,10 @@ bool recordStream()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

usleep(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -156,10 +156,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

// usleep(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void mediarecorder_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -289,10 +289,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

// usleep(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void audio_attention_cb(const ErrorAttentionParam *atprm)
Expand All @@ -48,7 +48,7 @@ static void audio_attention_cb(const ErrorAttentionParam *atprm)
}

/**
* @brief Setup recording of mp3 stream to file
* @brief Setup recording of wav stream to file
*
* Select input device as microphone <br>
* Initialize filetype to stereo wav with 48 Kb/s sampling rate <br>
Expand Down Expand Up @@ -174,10 +174,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

// usleep(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool ErrEnd = false;
/**
* @brief Audio attention callback
*
* When audio internal error occurc, this function will be called back.
* When audio internal error occurs, this function will be called back.
*/

static void mediarecorder_attention_cb(const ErrorAttentionParam *atprm)
Expand Down Expand Up @@ -279,10 +279,10 @@ void loop()
* Please adjust in according with the processing contents
* being processed at the same time by Application.
*
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
* The usleep() function suspends execution of the calling thread for usec
* microseconds. But the timer resolution depends on the OS system tick time
* which is 10 milliseconds (10,000 microseconds) by default. Therefore,
* it will sleep for a longer time than the time requested here.
*/

// usleep(10000);
Expand Down
Loading

0 comments on commit 8bfea4d

Please sign in to comment.