Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to understand what the 'frame' is you will have to read the <strong>standard</strong> of the wave file format. For instance: <a href="https://web.archive.org/web/20140221054954/http://home.roadrunner.com/~jgglatt/tech/wave.htm" rel="noreferrer">https://web.archive.org/web/20140221054954/http://home.roadrunner.com/~jgglatt/tech/wave.htm</a></p> <p>From that document:</p> <blockquote> <p>The sample points that are meant to be "played" ie, sent to a Digital to Analog Converter(DAC) simultaneously are collectively called a <strong>sample frame</strong>. In the example of our stereo waveform, every two sample points makes up another sample frame. This is illustrated below for that stereo example.</p> </blockquote> <pre><code>sample sample sample frame 0 frame 1 frame N _____ _____ _____ _____ _____ _____ | ch1 | ch2 | ch1 | ch2 | . . . | ch1 | ch2 | |_____|_____|_____|_____| |_____|_____| _____ | | = one sample point |_____| </code></pre> <p>To convert to mono you could do something like this,</p> <pre><code>import wave def stereo_to_mono(hex1, hex2): """average two hex string samples""" return hex((ord(hex1) + ord(hex2))/2) wr = wave.open('piano2.wav','r') nchannels, sampwidth, framerate, nframes, comptype, compname = wr.getparams() ww = wave.open('piano_mono.wav','wb') ww.setparams((1,sampwidth,framerate,nframes,comptype,compname)) frames = wr.readframes(wr.getnframes()-1) new_frames = '' for (s1, s2) in zip(frames[0::2],frames[1::2]): new_frames += stereo_to_mono(s1,s2)[2:].zfill(2).decode('hex') ww.writeframes(new_frames) </code></pre> <p>There is no clear-cut way to go from stereo to mono. You could just drop one channel. Above, I am averaging the channels. It all depends on your application.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload