Shop OBEX P1 Docs P2 Docs Learn Events
Noise Reduction Suggestions? — Parallax Forums

Noise Reduction Suggestions?

Hello. I'm kind of new to these forums. I was playing with the really cool audio demo in the propeller tool and trying to learn from it and noticed that recording audio from the jack on my Activity Board WX is fairly noisy. A lot of background hiss and all that. I was wondering if anyone here has suggestions to alleviate that.

Comments

  • Low-pass, Band-pass, High-pass and other tools!!!!

    http://sim.okawa-denshi.jp/en/Fkeisan.htm

    And getting the best results means that you select the best (expensive) IC:s you can find!
  • lol I'm not quite ready (or really able) to go full audiophile on it yet, but I really appreciate the link. Audacity does an okay job of removing the hiss, but it is still fairly noticeable (confirmed by someone else's first impressions unprompted). I was just hoping maybe I was doing something dumb on the software end, but I will give those a shot.
  • another try would be to run from batteries or a clean bench supply to avoid noise to get into the circuit.

    Enjoy!

    Mike
  • ErNaErNa Posts: 1,752
    edited 2020-09-19 11:31
    Hard to say, what your dominating problem is with noise, as noise by definition is of stochastic nature. So I would try to do some filtering. I understand the audio demo uses the internal sigma delta adc. Sampling frequency I assume is more then 20 kHz. The propeller is able to run filters in real time. You could for example average two or three consecutive samples. That is a sliding average. Or you could implement a RC-Filter by adding the latest value to an accumulator like this:
    ShiftRight := 0
    Accu := Accu - ShiftRight(Accu) + newSample

    OutValue := Accu

    This is quite senseless if ShiftRight == 0, because you substract Accu from Accu, add NewSample and output newSample. But just another example for a complex solution to a simple problem.
    But if ShiftRight == 1, you add to half of the Accumulator the new value what realizes a RC-filter., now you can play with ShiftRight to see, what happens.. Sorry: to hear what happens. We will see what happens November third.
  • ElectrodudeElectrodude Posts: 1,657
    edited 2020-09-19 18:04
    Another way to write that is:
    filtered += ((input - filtered) ** a) << 1
    
    where a is the 31-bit fractional part of (filter time constant)*(Δt), i.e. $4000_0000 represents dividing by three and corresponds to a shift of 1 in ErNa's example, and $2aaa_aaaa divides by about 3. This way more directly resembles the differential equation for a first-order RC filter. You could probably replace the ** a with shifts and adds, but if you're not doing it in PASM and you aren't using Fastspin it shouldn't make a significant difference. Note that this will fail if you try setting a to $8000_0000, because that actually represents -1.0, and not 1.0, so you'll need to add a special case or change the shifts around (probably losing yourself another bit of precision) if you anticipate that happening.

    If you used floating point, which I don't recommend due to its complexity and poor performance, it would just look like this:
    filtered += (input - filtered) * a
    

    EDIT: Fixed usage of **.
  • You could also use a FIR filter, which can automatically be generated as shown here:

    https://forums.parallax.com/discussion/133173/fir2pasm-automatic-fir-filter-code-generator/p1

    -Phil
  • ErNaErNa Posts: 1,752
    This is ASM code for the first order RC-Filter
            neg      scr,       ADCVal                ' new ADC counter value
            add      scr,       ADCValOld             ' substract old one
            shl      scr,       IntTimP               ' multiply value by 2^n
            add      ADCAccu,   scr                   ' add to average accumulator
            mov      ADCVal,    ADCAccu           
            sar      ADCVal,    #MaxAvrg              ' new averaged value
    
    This code is a little tricky. The problem with RC-filters is that changing the time constant changes the level of the accumulator. So every change of the time constant causes a bump in the signal. Here we have a normalized accumulator level so there is no bump.
    IntTimP is the time constant, MaxAvrg the highest possible value of the time constant. Take care that the accumulator can not overflow
  • Is the background hiss at a higher frequency than the audio?

    If so allow the audio to pass straight through from input to output (call this OUT1), and at the same time apply a HIGH-PASS filter to the input and output that as (OUT2). Treat OUT2 as an error correction for OUT1 in a PID loop.

    This is one of many tricks used in noise cancellation headphones. Another trick is to use FFT to denote stationary frequencies present in the input and apply that similarly into a PID as well.
  • feng wrote: »
    Low-pass, Band-pass, High-pass and other tools!!!!

    http://sim.okawa-denshi.jp/en/Fkeisan.htm

    And getting the best results means that you select the best (expensive) IC:s you can find!

    Thanks for the reminder!
    I already had these calculators bookmarked but forgot about them.
    I have been having trouble with stabilising a couple of servo motors, to no avail. Your post prompted me to look at my LPF and wouldn't you know it :lol:

    My little pack of caps, clearly state 2.2nf and so I checked them with my meter... Whoa, 2.2uf!!!!

    I source my parts from a big-name vendor and this is not the first time that this has happened.
    I lost a day, playing with my PID and looking for mechanical backlash (position feedback is on the load)

    Regards,
    Craig
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2020-09-20 17:13
    Try this:
    http://forums.parallax.com/discussion/141346/yet-another-wave-player-now-nco-based-and-noise-almost-free

    Which output method is used in "really cool audio demo in the propeller tool"? If it is duty mode PWM, the noise may be due to the high intrinsic subharmonic content of that method. The method suggested by PIK33 uses a standard single-frequency PWM with noise shaping.

    Also this followup...
    http://forums.parallax.com/discussion/148280/prop-sound-quality-question

Sign In or Register to comment.