0
$\begingroup$

When I print the result of the first audio frame by doing track.readframes(1), I get b'\xfb\xff\xfb\xfe'. My track is stereo so we know that we have 2 channels where each channel has 1 sample. Does it mean that the left channel sample is : 'fbff' and the right one is 'fbfe'?

$\endgroup$
11
  • 1
    $\begingroup$ Hi! This seems to be more of a general programming than a signal processing question. Also, the byte order actually depends on the type of data in your WAV, so there's no single answer to your question. $\endgroup$ Commented Apr 4 at 12:49
  • $\begingroup$ Thanks for your answer Marcus. I am actually trying to read the frames of a wav song and then get the samples of it. The track is stereo so we know that each channel should have 1 sample that's why I assumed the above. $\endgroup$
    – user71782
    Commented Apr 4 at 13:00
  • $\begingroup$ don't assume - you don't say which of the multiple python-wrapped audio file reading libraries you use, but its documentation should tell you exactly how to figure that out. $\endgroup$ Commented Apr 4 at 13:01
  • $\begingroup$ Oh, I said that on the title, I am using the wave library and unfortunately, its documentation and google info are poor. $\endgroup$
    – user71782
    Commented Apr 4 at 13:24
  • $\begingroup$ ah you mean the python3 builtin wave module with "wave library", sorry, I was being a bit thick there. Yeah, the documentation could be better. But it's all there: getsampwidth will tell you how much bits there are per sample, and they are indeed in order. However, don't use the wave module in a cross-platform context; it always assumes Little-endian data, and that's not true for all wav files. Also, it can't deal with any compressed audio, doesn't even try to support you guessing whether a 4-byte sample is a 32 bit little endian integer, bit endian integer, or floating point number,… $\endgroup$ Commented Apr 4 at 13:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.