Last active
June 14, 2023 16:08
-
-
Save Tolsi/2c7580d30e6b45a598be1ccce95d55bc to your computer and use it in GitHub Desktop.
Revisions
-
Tolsi revised this gist
Dec 14, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ import wave, array # changed from https://stackoverflow.com/a/43163543/699934 def make_stereo(file1, file2, output): ifile1 = wave.open(file1) ifile2 = wave.open(file2) -
Tolsi created this gist
Dec 14, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import wave, array def make_stereo(file1, file2, output): ifile1 = wave.open(file1) ifile2 = wave.open(file2) print(ifile1.getparams()) # (1, 2, 44100, 2013900, 'NONE', 'not compressed') (nchannels, sampwidth, framerate, nframes, comptype, compname) = ifile1.getparams() assert ifile1.getparams() == ifile2.getparams() assert comptype == 'NONE' # Compressed not supported yet array_type = {1:'B', 2: 'h', 4: 'l'}[sampwidth] left_channel = array.array(array_type, ifile1.readframes(nframes))[::nchannels] right_channel = array.array(array_type, ifile2.readframes(nframes))[::nchannels] ifile1.close() ifile2.close() stereo = 2 * left_channel stereo[0::2] = left_channel stereo[1::2] = right_channel ofile = wave.open(output, 'w') ofile.setparams((2, sampwidth, framerate, nframes, comptype, compname)) ofile.writeframes(stereo) ofile.close()