Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.85.MISMATCH!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.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'output': 0.04; 'aahz': 0.05; 'mrab': 0.05; '128': 0.09; 'input,': 0.09; 'unsigned': 0.09; 'cc:addr:python-list': 0.10; "wouldn't": 0.11; 'value.': 0.15; '(eg.': 0.16; 'inputs': 0.16; 'loud': 0.16; 'passes,': 0.16; 'storing': 0.16; 'wrote:': 0.17; 'combination': 0.22; 'default,': 0.22; 'simpler': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'programming': 0.23; 'cc:no real name:2**0': 0.24; 'signed': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'values': 0.26; 'scale': 0.27; 'rest': 0.28; 'equivalent,': 0.29; 'probably': 0.29; 'normally': 0.30; 'could': 0.32; 'adjust': 0.33; 'controls': 0.33; 'values.': 0.33; 'done': 0.34; 'pm,': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'possible': 0.37; 'level': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'think': 0.40; 'your': 0.60; 'places': 0.61; 'side': 0.61; 'maximum': 0.63; 'more': 0.63; 'sound': 0.65; 'overall': 0.66; 'sum': 0.66; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'article': 0.78; 'gain': 0.79; 'average.': 0.84; 'booming': 0.84; "it'd": 0.84; 'max.': 0.84; 'musical': 0.84; 'stereo': 0.84; 'dynamics': 0.91 Date: Sat, 10 Nov 2012 08:05:00 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Aahz Subject: Re: Numpy combine channels References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:L75k3P/Kyqp3foF7wtpYm0OwoNU7Gl7++Yeha8xen52 TyXSFCDk3A5PxYYQ91vf2o9bvH69IkxKuG2bl6qrdFiG2QnYiV mcWItEwRpO6tBuakOBHZyMRd8jlZDghFm7ZjZmuBlm0C/zZRUU +AZQNoNnJoXeJ4DYkDFuhoPwm7bV9EOE+vhTMFBONdbh0+UUYC 7HJgZYiINontifVDCMzgiYN4MmTgOkAclQROnGCFA3P5GCHAC9 Db1zOrocnCRhduqknhtS96hcQSiOYBs105CSEICp81kYbod5Eu gOghs3/dsAn4pT0XM8FU5ZwX1VMHRUJSuQ4XPuVl2GeYzNInA= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352552737 news.xs4all.nl 6930 [2001:888:2000:d::a6]:55317 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33085 On 11/09/2012 11:30 PM, Aahz wrote: > In article , > MRAB wrote: >> >> >> 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? max would sound awful. The right answer is to add them with weighting, then scale the whole waveform according to a new calculation of clipping. Just like a mixer, you have level controls on each input, then an overall gain. So if the inputs were x and y, the output would be gain *( x_scale * x + y_scale * y), but it'd normally be done in two passes, so as to minimize the places that are clipped, while maximizing the average. it's also possible to have gain vary across the time axis, like an agc. But you wouldn't want that as a default, as it'd destroy the dynamics of a musical piece. One more consideration. If these are unsigned values (eg. 0 to 255), then you should adjust both signals by 128 before storing them as signed values, do your arithmetic, and then adjust again by adding 128. You could do the algebraic equivalent, but the programming would be much simpler on signed values. -- DaveA