From owner-freebsd-multimedia@FreeBSD.ORG Wed May 14 10:57:41 2014 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3444BED for ; Wed, 14 May 2014 10:57:41 +0000 (UTC) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B049B239A for ; Wed, 14 May 2014 10:57:40 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id D85CD1FE029; Wed, 14 May 2014 12:57:30 +0200 (CEST) Message-ID: <53734C4D.8090103@selasky.org> Date: Wed, 14 May 2014 12:58:21 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Ian Smith Subject: Re: OSS mains HUM filtering 50Hz / 60Hz ? References: <537264F6.5060808@selasky.org> <53732425.7070600@selasky.org> <20140514193740.D11699@sola.nimnet.asn.au> In-Reply-To: <20140514193740.D11699@sola.nimnet.asn.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-multimedia@freebsd.org X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 10:57:41 -0000 On 05/14/14 12:12, Ian Smith wrote: > On Wed, 14 May 2014 10:07:01 +0200, Hans Petter Selasky wrote: > > On 05/13/14 20:31, Hans Petter Selasky wrote: > > > Hi, > > > > > > Some of my USB audio headsets seems to be picking up mains HUM even if > > > powered from battery. At first I thought the mains HUM came from the > > > computer, but then I did some work and I verified my findings by > > > sampling the AC network using a non-switching power supply. Maybe it > > Hmm, by non-switching I suppose you mean via a transformer .. the ripple > quality won't necessarily be better than a switched supply; it's down to > the final filtering usually. Hi Ian, Right, via a transformer and a simple voltage regulator I think. > > Any HV power lines or an electricity sub-station near you? (induction) I need to check it out. > > > > does not belong in the FreeBSD audio stack, but I think it would be very > > > clever to have a configurable band-reject filter in the FreeBSD DSP > > > framework for 50 and 60Hz? Do we have such a filter mechanism already? > > > > > > Not sure if this is a so-called "feature" or not ... :-) > > > > > > http://en.wikipedia.org/wiki/Mains_hum > > > > > > http://www.selasky.org/hans_petter/hum.png > > Are those units mV, or what? It is not mV. I simply scaled the output from the transformer 12V using some KOhm resistors and recorded that using another sound card. I just wanted to check if the received hum was actually from the power grid or not, and looking at the phase, indeed it was. > > > I tried the following patch with some success: > > > > === pcm/feeder_chain.c > > ================================================================== > > --- pcm/feeder_chain.c (revision 265912) > > +++ pcm/feeder_chain.c (local) > > @@ -721,7 +721,7 @@ > > > > /* Soft EQ only applicable for PLAY. */ > > I'm wondering why Ariff chose to only apply it for playback? > > > if (cdesc.dummy == 0 && > > - c->direction == PCMDIR_PLAY && (d->flags & SD_F_EQ) && > > + (d->flags & SD_F_EQ) && > > (((d->flags & SD_F_EQ_PC) && > > !(c->flags & CHN_F_HAS_VCHAN)) || > > (!(d->flags & SD_F_EQ_PC) && !(c->flags & > > CHN_F_VIRTUAL)))) > cdesc.use_eq = 1; > > Can you give a quick pointer to the actual EQ code (just curious as to > how it's done, having just taken the pcm code on faith so far). I tested the patch above and it seems to work. It works for both RX and TX'ed audio. > > > And setting: > > > > hint.pcm.0.eq=1 > > hint.pcm.1.eq=1 > > hint.pcm.2.eq=1 > > hint.pcm.3.eq=1 > > If that turns out to be a real solution to this problem, might we then > need separate en/disabling of PLAY and REC eq? I think the problem is a bit more complicated. I ended up routing the audio signal through a real software EQ using JACK, and that seems to do the trick a bit better. > > Here I'm directly generating 24-bit wave files, some of which are around > 50Hz (plus harmonics), and some occasionally as low as ~22Hz, so I need > specifically to not suppress these on playback, though finding amps or > headphones that don't dampen these freqs too much can be fun .. Of course, the USB audio equipment I'm talking about in this case is not professional. All 16-bit cheap headset stuff. Although I was surprised about the level of hum and I also noticed that this audio device from Logitech, also is sensitive to 2.4GHz .... When using a wireless mouse it also picks up noise from that one ... :-) On the other hand I'm not surprised if this is a so-called "feature" ;-) --HPS