Numpy combine channels
Wanderer
wanderer at dialup4less.com
Mon Sep 10 16:14:18 EDT 2012
On Monday, September 10, 2012 4:12:40 PM UTC-4, MRAB 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'm decoding morse code. So it's CV dots and dashes.
More information about the Python-list
mailing list