Audio-tools: How to write a complete WAV file to SD card - with header? #658
-
Thank you so much Phil for your work! |
Beta Was this translation helpful? Give feedback.
Replies: 20 comments 13 replies
-
If you write it thru a WAVEncoder the header should get added to it automatically! |
Beta Was this translation helpful? Give feedback.
-
There is no WAVEEncoder.h library in arduino-audio-tools. There is a WAVEncoder() class in the CodecWAV.h library |
Beta Was this translation helpful? Give feedback.
-
EncodedAudioStream out_stream(&file, new WAVEncoder()); // encode as wav file |
Beta Was this translation helpful? Give feedback.
-
void record_end(bool pinStatus, int pin, void* ref){ |
Beta Was this translation helpful? Give feedback.
-
"Yes that't the one and that you can find in the documentation!" |
Beta Was this translation helpful? Give feedback.
-
It's automatically included so you don't need to include it a second time. |
Beta Was this translation helpful? Give feedback.
-
Each time the file is overwritten, but always without a header. #include "AudioTools.h" //const char *file_name = "/rec.wav"; void record_start(bool pinStatus, int pin, void* ref){ // Open SD drive // setup input and output // Configure out stream // record when key 1 is pressed } void loop(){ if(recording == true){ } |
Beta Was this translation helpful? Give feedback.
-
yes i just add files. |
Beta Was this translation helpful? Give feedback.
-
If you look at the content of the WAV file the header starts with the content "RIFF" |
Beta Was this translation helpful? Give feedback.
-
I think your logic to create a decoder looks completly wrong to me! If you set the log level to Info you should see the message "Writing Header" in the log |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your help. Everything worked as expected! The file header is recorded, the sound is great! I |
Beta Was this translation helpful? Give feedback.
-
I guess the remove fails if the file is still open. In order to overwrite the content you can also just move the file pointer to the beginning with file.lseek(0); |
Beta Was this translation helpful? Give feedback.
-
Good day. There was one more question about the operation of the audio player from the SD card. If, after stopping the player, remove the SD card and insert it back (or another card), the player will no longer start. Moreover, the initialization of the SD card (sd.begin (config)) is successful. The problem turned out to be in the AudioSourceSDFAT.h file. |
Beta Was this translation helpful? Give feedback.
-
For the time being I do not plan to change this. On my drive the sd.begin has a high rate of failing, so I avoid to call this method. |
Beta Was this translation helpful? Give feedback.
-
@Nik-mayak can you share the final working code as I am also struggling with this... |
Beta Was this translation helpful? Give feedback.
-
Are you struggling writing a wav file or with replacing the SD w/o restarting ? |
Beta Was this translation helpful? Give feedback.
-
I will answer you a little later :)
чт, 4 мая 2023 г., 10:26 Miroslav Petrov ***@***.***>:
… @Nik-mayak <https://github.com/Nik-mayak> can you share the final working
code as I am also struggling with this...
—
Reply to this email directly, view it on GitHub
<#658 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AR6JPIZHLXRPYMJD5C46I6TXENRZVANCNFSM6AAAAAAVNQNLYU>
.
You are receiving this because you were mentioned.Message ID:
<pschatzmann/arduino-audio-tools/repo-discussions/658/comments/5802254@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
If you follow the Wiki about encoding and decoding the excercise should be trivial. If you want to process another output do not forget to call out.begin(info); again. Otherwise the output does not know that you restarted and it will not write a wav header... |
Beta Was this translation helpful? Give feedback.
-
main.zip |
Beta Was this translation helpful? Give feedback.
-
I just nailed down where the issue is: In the AudioKit the RX mode seens to be broken and does not produce any signal any more. |
Beta Was this translation helpful? Give feedback.
If you write it thru a WAVEncoder the header should get added to it automatically!
This is also how the Webserver examples are working: the Wav header makes that the browser is recognising the file format.
The header is added when the first write is called before the audio data is written.