Stereo to Mono wav in Python
First, what is the datatype of audiodata
? I assume it's some fixed-width integer format and you therefore get overflow. If you convert it to a floating point format before processing, it will work fine:
audiodata = audiodata.astype(float)
Second, don't write your Python code element by element; vectorize it:
d = (audiodata[:,0] + audiodata[:,1]) / 2
or even better
d = audiodata.sum(axis=1) / 2
This will be vastly faster than the element-by-element loop you wrote.
turns out, all i had to change was
(right+left)/2
to
(right/2) + (left/2)