Skip to content

Commit 182c210

Browse files
committed
Corrected logs to show when speed / pitch has been changed
1 parent bd13fba commit 182c210

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

examples/audio_processing/pipeline_sonic/main/sonic_example.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "freertos/task.h"
1313
#include "freertos/timers.h"
1414
#include "esp_log.h"
15-
#include "sdkconfig.h"
1615
#include "audio_element.h"
1716
#include "audio_pipeline.h"
1817
#include "audio_event_iface.h"
@@ -35,7 +34,7 @@ static const char *TAG = "SONIC_EXAMPLE";
3534
#define BITS 16
3635

3736
#define SONIC_PITCH 1.4f
38-
#define SONIC_SPEED 1.3f
37+
#define SONIC_SPEED 2.0f
3938

4039
static audio_element_handle_t create_sonic()
4140
{
@@ -136,6 +135,7 @@ void record_playback_task()
136135
audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG();
137136
audio_event_iface_handle_t evt = audio_event_iface_init(&evt_cfg);
138137
audio_event_iface_set_listener(esp_periph_get_event_iface(), evt);
138+
ESP_LOGW(TAG, "Press [Rec] to start recording");
139139
bool is_modify_speed = true;
140140
while (1) {
141141
audio_event_iface_msg_t msg;
@@ -149,19 +149,20 @@ void record_playback_task()
149149
}
150150
if ((int)msg.data == GPIO_MODE) {
151151
if ((msg.cmd == PERIPH_BUTTON_LONG_PRESSED)
152-
|| (msg.cmd == PERIPH_BUTTON_PRESSED)){
152+
|| (msg.cmd == PERIPH_BUTTON_PRESSED)) {
153153
is_modify_speed = !is_modify_speed;
154-
}
155-
continue;
154+
if (is_modify_speed) {
155+
ESP_LOGI(TAG, "The speed of audio file is changed");
156+
} else {
157+
ESP_LOGI(TAG, "The pitch of audio file is changed");
158+
}
159+
}
160+
continue;
156161
}
157-
if (is_modify_speed) {
158-
ESP_LOGI(TAG, "The speed of audio file is changed");
159-
} else {
160-
ESP_LOGI(TAG, "The pitch of audio file is changed");
161-
}
162162
if ((int)msg.data == GPIO_REC) {
163163
if (msg.cmd == PERIPH_BUTTON_PRESSED) {
164-
ESP_LOGE(TAG, "STOP Playback and START [Record]"); //using LOGE to make the log color different
164+
//using LOGE to make the log color different
165+
ESP_LOGE(TAG, "Now recording, release [Rec] to STOP");
165166
audio_pipeline_stop(pipeline_play);
166167
audio_pipeline_wait_for_stop(pipeline_play);
167168

@@ -174,7 +175,7 @@ void record_playback_task()
174175
audio_element_set_uri(fatfs_writer_el, "/sdcard/rec.wav");
175176
audio_pipeline_run(pipeline_rec);
176177
} else if (msg.cmd == PERIPH_BUTTON_RELEASE || msg.cmd == PERIPH_BUTTON_LONG_RELEASE) {
177-
ESP_LOGI(TAG, "STOP [Record] and START Playback");
178+
ESP_LOGI(TAG, "START Playback");
178179
audio_pipeline_stop(pipeline_rec);
179180
audio_pipeline_wait_for_stop(pipeline_rec);
180181

0 commit comments

Comments
 (0)