Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WAV recording not always works fine #2114

Answered by hash6iron
hash6iron asked this question in Q&A
Discussion options

Hello @pschatzmann.

I try to coded a simple WAV recorder, to capture audio from LineIn jack of Audiokit A1S with ES8388v2, but not always the file end fine, sometimes the file is closed good and is possible to play the file under windows but others says corrupt file .

This is the simple code. kitStream is the object of board. The same configuration is used to play MP3 and capture samples without problems.

Could you help me to know where is the issue of file corruption?
Thanks in advance.

Code

new_sr.sample_rate = 22050;
kitStream.setAudioInfo(new_sr); 
 
AudioInfo enc_sr = encoderOutWAV.defaultConfig();
enc_sr.sample_rate = 22050;
encoderOutWAV.setAudioInfo(enc_sr);
MultiOutput cmulti; 
StreamCopy copier(cmulti, kitStream); // copies data to both file and line_out 
 
cmulti.add(encoderOutWAV);
cmulti.add(kitStream);
AudioInfo ecfg = encoderOutWAV.defaultConfig();
ecfg.sample_rate = 22050;
ecfg.channels = 2;
ecfg.bits_per_sample = 16;
encoderOutWAV.setAudioInfo(ecfg); 
// recording loop until STOP flag!
while (!STOP)
{
 copier.copy();
}
// End stream and closing file.
copier.end();
cmulti.end();
wavfile.flush();
wavfile.close();
You must be logged in to vote

I already solve the problem. Is needed encoderOutStream.begin() always for each new WAV file.

Replies: 2 comments 1 reply

Comment options

I already solve the problem. Is needed encoderOutStream.begin() always for each new WAV file.

You must be logged in to vote
0 replies
Answer selected by pschatzmann
Comment options

.. as you can find in the documentation...

You must be logged in to vote
1 reply
Comment options

Yes. I found the solution in the documentation. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /