Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 0787669

Browse files
fpistmalfran
authored andcommitted
Fix Audio recorder issue.
Remove some delay. When Audio.begin() is called, recording is started. Audio out volume have also be set in case of audio in. Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent 184c385 commit 0787669

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

libraries/Audio/example/SimpleAudioRecorder/SimpleAudioRecorder.ino

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <SD.h>
2121
#include <Audio.h>
2222

23-
const char recFile[] = "test.wav";
23+
const char recFile[] = "record.wav";
2424
#define AUDIO_IN_FREQUENCY BSP_AUDIO_FREQUENCY_48K
2525
#define DEFAULT_TIME_REC 30 // Recording time in second (default: 30s)
2626
#define REC_SAMPLE_LENGTH (DEFAULT_TIME_REC * AUDIO_IN_FREQUENCY * DEFAULT_AUDIO_IN_CHANNEL_NBR * 2)
@@ -95,7 +95,6 @@ void loop() {
9595

9696
delay(1000);
9797
SerialUSB.println("Starting AUDIO recorder");
98-
delay(1000);
9998
status = Audio.begin(WaveFormat.SampleRate, 100, AUDIO_IN);
10099
if (status != 0) {
101100
SerialUSB.print("Error: Audio could not begin: ");
@@ -105,13 +104,11 @@ void loop() {
105104
SerialUSB.println("Audio begin: OK");
106105
}
107106

108-
delay(1000);
109-
110107
// Prepare samples
111108
SerialUSB.println("Recording...");
112109
int volume = 100;
113110
Audio.prepare(NULL, S, volume);
114-
delay(1000);
111+
delay(100);
115112

116113
// MAX Recording time reached, so stop audio interface and close file
117114
while ( Audio.getSampleIn() < REC_SAMPLE_LENGTH) {

libraries/Audio/src/Audio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ uint32_t AudioClass::amp(uint8_t volume, AudioMode audioMode) {
189189
uint32_t ret = AUDIO_OK;
190190
if ((!audio_in_init) && (!audio_out_init))
191191
ret = AUDIO_ERROR;
192-
if ((audio_out_init) && (audioMode != AUDIO_IN))
192+
if ((audio_out_init) || (audio_in_init))
193193
ret = BSP_AUDIO_OUT_SetVolume(volume);
194194
if ((audio_in_init) && (audioMode != AUDIO_OUT))
195195
ret |= BSP_AUDIO_IN_SetVolume(volume);

0 commit comments

Comments
 (0)