12
12
#include "freertos/task.h"
13
13
#include "freertos/timers.h"
14
14
#include "esp_log.h"
15
- #include "sdkconfig.h"
16
15
#include "audio_element.h"
17
16
#include "audio_pipeline.h"
18
17
#include "audio_event_iface.h"
@@ -35,7 +34,7 @@ static const char *TAG = "SONIC_EXAMPLE";
35
34
#define BITS 16
36
35
37
36
#define SONIC_PITCH 1.4f
38
- #define SONIC_SPEED 1.3f
37
+ #define SONIC_SPEED 2.0f
39
38
40
39
static audio_element_handle_t create_sonic ()
41
40
{
@@ -136,6 +135,7 @@ void record_playback_task()
136
135
audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG ();
137
136
audio_event_iface_handle_t evt = audio_event_iface_init (& evt_cfg );
138
137
audio_event_iface_set_listener (esp_periph_get_event_iface (), evt );
138
+ ESP_LOGW (TAG , "Press [Rec] to start recording" );
139
139
bool is_modify_speed = true;
140
140
while (1 ) {
141
141
audio_event_iface_msg_t msg ;
@@ -149,19 +149,20 @@ void record_playback_task()
149
149
}
150
150
if ((int )msg .data == GPIO_MODE ) {
151
151
if ((msg .cmd == PERIPH_BUTTON_LONG_PRESSED )
152
- || (msg .cmd == PERIPH_BUTTON_PRESSED )){
152
+ || (msg .cmd == PERIPH_BUTTON_PRESSED )) {
153
153
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 ;
156
161
}
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
- }
162
162
if ((int )msg .data == GPIO_REC ) {
163
163
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" );
165
166
audio_pipeline_stop (pipeline_play );
166
167
audio_pipeline_wait_for_stop (pipeline_play );
167
168
@@ -174,7 +175,7 @@ void record_playback_task()
174
175
audio_element_set_uri (fatfs_writer_el , "/sdcard/rec.wav" );
175
176
audio_pipeline_run (pipeline_rec );
176
177
} 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" );
178
179
audio_pipeline_stop (pipeline_rec );
179
180
audio_pipeline_wait_for_stop (pipeline_rec );
180
181
0 commit comments