read sample_rate, channels, bits_per_sample from unknown .wav file #673
-
Hello, I would like to position playback of an .wav file on SD to a specific time. The position in terms of bytes can be easily converted if sample_rate, channels, bits_per_sample are known. I am aware of the setNotifyAudioChange function which allows me to properly output different .wav files, but how can I access these data directly in my code? Thanks for your help and best regards, Werner |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Why don't you just use the file api and do a lseek to the required position... |
Beta Was this translation helpful? Give feedback.
-
Just write the header and then this information will be available. I suggest that you have a look at the WavDecoder documentation |
Beta Was this translation helpful? Give feedback.
-
After the first copy the EncodedAudioStream knows this information and you can get it with decoder.audioInfo(). So you could add you first copier.copy(); to the setup, so that you have this available in the loop. If this is too crude you can replace the copy with your own logic of reading from the file and writing to the destination. The wav header has 44 bytes, so that's the min amount of data that you need to write to get this information. |
Beta Was this translation helpful? Give feedback.
Why don't you just use the file api and do a lseek to the required position...