File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -228,13 +228,26 @@ void AUDIO_Record(void *pvParameters)
228
228
229
229
ESP_LOGI (TAG , "File opened" );
230
230
231
+ // Determines how many samples we want to save
232
+ const size_t target_samples_written = param -> duration_sec * AUDIO_INPUT_SAMPLE_FREQ ;
233
+ size_t bytes_received = 0 ;
234
+ size_t samples_written = 0 ;
235
+
231
236
// write wav header
232
237
wav_header_t wav_header = {
233
- .Subchunk1ID = "fmt" ,
234
- .Subchunk2ID = "data" ,
235
- .SampleRate = AUDIO_INPUT_SAMPLE_FREQ ,
238
+ .ChunkID = "RIFF" ,
239
+ .ChunkSize = (2 * target_samples_written ) - 8 ,
240
+ .Format = "WAVE" ,
241
+ .Subchunk1ID = "fmt " ,
242
+ .Subchunk1Size = 16 ,
243
+ .AudioFormat = 1 ,
236
244
.NumChannels = 1 ,
237
- .BitsPerSample = 16 };
245
+ .SampleRate = AUDIO_INPUT_SAMPLE_FREQ ,
246
+ .ByteRate = 64000 ,
247
+ .BlockAlign = 2 ,
248
+ .BitsPerSample = 16 ,
249
+ .Subchunk2ID = "data" ,
250
+ .Subchunk2Size = target_samples_written * 2 };
238
251
239
252
int len = fwrite (& wav_header , 1 , sizeof (wav_header_t ), fd );
240
253
@@ -243,11 +256,6 @@ void AUDIO_Record(void *pvParameters)
243
256
ESP_LOGE (TAG , "Read wav header failed" );
244
257
}
245
258
246
- // Determines how many samples we want to save
247
- const size_t target_samples_written = param -> duration_sec * AUDIO_INPUT_SAMPLE_FREQ ;
248
- size_t bytes_received = 0 ;
249
- size_t samples_written = 0 ;
250
-
251
259
ESP_LOGI (TAG , "Waiting for squelch to open" );
252
260
253
261
while (1 )
You can’t perform that action at this time.
0 commit comments