Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'skip:[ 20': 0.03; 'that?': 0.05; '[1,': 0.09; 'value.': 0.15; '2],': 0.16; '[2,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'numpy': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'import': 0.21; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'looks': 0.26; 'received:192.168.1.3': 0.29; 'array': 0.29; 'probably': 0.29; 'to:addr:python-list': 0.33; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'maximum': 0.63; 'sum': 0.66; 'header:Reply-To:1': 0.68; 'skip:n 30': 0.69; 'reply-to:no real name:2**0': 0.72; 'average.': 0.84; 'reply- to:addr:python.org': 0.84; 'stereo': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=W6e6pGqk c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=lR6CHUT36vYA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=kZIQh7jScyYA:10 a=PeOeGrWN0p5IMPFtStkA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Mon, 10 Sep 2012 21:11:46 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Numpy combine channels References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347307911 news.xs4all.nl 6984 [2001:888:2000:d::a6]:37533 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28848 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])