Numpy combine channels
Aahz
aahz at pythoncraft.com
Sat Nov 10 05:30:03 CET 2012
In article <mailman.465.1347307911.27098.python-list at python.org>,
MRAB <python-list at python.org> wrote:
>On 10/09/2012 20:39, Wanderer wrote:
>>
>> I have an array generated by audiolab of left and right stereo
>> channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine
>> the left and right channels to get an array [2,3,5]. Is there a numpy
>> command to do that?
>
>>>> import numpy
>>>> numpy.array([[1,1],[1,2],[2,3]], dtype="i")
>array([[1, 1],
> [1, 2],
> [2, 3]])
>>>> a[:, 0]
>array([1, 1, 2])
>>>> a[:, 1]
>array([1, 2, 3])
>>>> a[:, 0] + a[:, 1]
>array([2, 3, 5])
>
>But should they be added together to make mono?
>
>Suppose, for example, that both channels have a maximum value. Their
>sum would be _twice_ the maximum.
>
>Therefore, I think that it should probably be the average.
>
> >>> (a[:, 0] + a[:, 1]) / 2
>array([1, 1, 2])
I'd actually think it should be the max. Consider a stereo where one
side is playing a booming bass while the other side is playing a rest
note -- should the mono combination be half as loud as as the bass?
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"....Normal is what cuts off your sixth finger and your tail..." --Siobhan
More information about the Python-list
mailing list