Produce anti-noise

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sebb

    Produce anti-noise

    I want to know if the is a way to do something in python to produce
    some anti-noise (i.e. I talk in the microphone and the sound go out by
    the speakers but with inversed phase).

    So I want to know how to control the microphone and to add some sort
    of effect to the sound that enter in and to put it out with that
    effect and all this at the same time.


    Thanks
  • Diez B. Roggisch

    #2
    Re: Produce anti-noise

    > I want to know if the is a way to do something in python to produce[color=blue]
    > some anti-noise (i.e. I talk in the microphone and the sound go out by
    > the speakers but with inversed phase).
    >
    > So I want to know how to control the microphone and to add some sort
    > of effect to the sound that enter in and to put it out with that
    > effect and all this at the same time.[/color]

    AFAIK such things need vast amounts of computational power for very
    complicated algorithms and very low latencies - a job for specialised DSP
    code. Its much more complicated than inverting the amplitude (I don't think
    that inverting the phase is possible - AFAIK you can only shift it, and
    thats not what you want here...)

    So I seriously doubt that you can do that with python - I even doubt that
    you can do it with you computer. Not so much from the raw computational
    power side of the thing, but much more from your audio-equipment.
    Professional noise reduction systems costs several thousands of euro and
    feature lots of speakers, especially designed, chosen and arranged to
    reflect the acoustic envrionment of _one_ room, e.g. the inside of a
    certain car. Then specially adapted algorithms come into play.

    And AFAIK they only do a decent job of suppressing predictable signals -
    like noise from rolling tyres, wind and engines.

    Look at www.bose.de, at least in german they have some explanations on whats
    actually going on.

    However, it _is_ possible to access microphone and speakers - look for
    portaudio or rtaudio-0.2b (for alsa/linux)

    Regards,

    Diez

    Comment

    • David Konerding

      #3
      Re: Produce anti-noise

      In article <bvmlik$kam$06$ 1@news.t-online.com>, Diez B. Roggisch wrote:[color=blue][color=green]
      >> I want to know if the is a way to do something in python to produce
      >> some anti-noise (i.e. I talk in the microphone and the sound go out by
      >> the speakers but with inversed phase).
      >>
      >> So I want to know how to control the microphone and to add some sort
      >> of effect to the sound that enter in and to put it out with that
      >> effect and all this at the same time.[/color]
      >
      > AFAIK such things need vast amounts of computational power for very
      > complicated algorithms and very low latencies - a job for specialised DSP
      > code. Its much more complicated than inverting the amplitude (I don't think
      > that inverting the phase is possible - AFAIK you can only shift it, and
      > thats not what you want here...)
      >
      > So I seriously doubt that you can do that with python - I even doubt that
      > you can do it with you computer. Not so much from the raw computational
      > power side of the thing, but much more from your audio-equipment.
      > Professional noise reduction systems costs several thousands of euro and
      > feature lots of speakers, especially designed, chosen and arranged to
      > reflect the acoustic envrionment of _one_ room, e.g. the inside of a
      > certain car. Then specially adapted algorithms come into play.[/color]

      Hmm. You can buy a $200 set of bose headphones that do it with a simple chip and low power.
      I think a regular PC could do this (so long as you know the equations) by brute force. You'd probably want to
      use signal processing libraries rather than pure Python, though.

      Comment

      • Josiah Carlson

        #4
        Re: Produce anti-noise

        Perhaps I'm not understanding the original question, but if one can get
        the signed (-32768...32767) audio input signals, make it into a numeric
        array (using Numeric or what have you), multiply that numeric array by
        -1, then output the signal, it would be relatively easy to invert the phase.

        About the only question is whether or not there is significant overhead
        in reading the audio signal, inverting it, then sending the audio signal
        back to some set of speakers.


        Personally, I'm a big fan of the low-tech approach:
        Cut the cable in your microphone, swap the wires, seal the cable.

        Adjust the volume on your input microphones (for noise cancellation, one
        should optimally have one for each ear), and you are set.


        I read an article for doing this kind of thing using just a few
        transistors and a 9V battery to produce a few mW amp and a a pair of
        very small standard microphones in an electronics hobby book in ~1998.

        - Josiah

        Comment

        • Diez B. Roggisch

          #5
          Re: Produce anti-noise

          > Perhaps I'm not understanding the original question, but if one can get[color=blue]
          > the signed (-32768...32767) audio input signals, make it into a numeric
          > array (using Numeric or what have you), multiply that numeric array by
          > -1, then output the signal, it would be relatively easy to invert the
          > phase.[/color]

          Then you didn't inverse the phase, but amplitude. Phases can be shift.

          Regards,

          Diez

          Comment

          • Diez B. Roggisch

            #6
            Re: Produce anti-noise

            > Hmm. You can buy a $200 set of bose headphones that do it with a simple[color=blue]
            > chip and low power.
            > I think a regular PC could do this (so long as you know the equations) by
            > brute force. You'd probably want to use signal processing libraries
            > rather than pure Python, though.[/color]

            I'm no acoustics expert, so I'm sort on the speculative side here. But I
            described a different scenario: speakers _not_ attached close to your ear.
            Then the room accoustics and the place of reception have to be taken into
            account. Otherwise, the signal that reaches your ear would have shifts and
            other artifacts.

            OTOH, when you wear headphones, the scenario seems much simpler, as you then
            can detect and produce the appropriate sounds close to the ear. This seem
            to be easier.

            So, it depends on what the OP had in mind.

            Regards,

            Diez

            Comment

            • Josiah Carlson

              #7
              Re: Produce anti-noise

              >>Perhaps I'm not understanding the original question, but if one can get[color=blue][color=green]
              >>the signed (-32768...32767) audio input signals, make it into a numeric
              >>array (using Numeric or what have you), multiply that numeric array by
              >>-1, then output the signal, it would be relatively easy to invert the
              >>phase.[/color]
              >
              >
              > Then you didn't inverse the phase, but amplitude. Phases can be shift.[/color]

              You are right, I had it confused with something else.

              I am curious though, isn't an inverse in phase just a phase shift of 180
              degrees? If so, shouldn't inverting the phases of all input waveforms
              (if we were to decompose the signal) produce an output that is
              funnctionally an amplitude inversion?

              - Josiah

              Comment

              • Gerrit Holl

                #8
                Re: Produce anti-noise

                Josiah Carlson wrote:[color=blue]
                > I am curious though, isn't an inverse in phase just a phase shift of 180
                > degrees? If so, shouldn't inverting the phases of all input waveforms
                > (if we were to decompose the signal) produce an output that is
                > funnctionally an amplitude inversion?[/color]

                That's only true for sin(x).

                I think a phase shift is measured in time or as a fraction of the
                period, not in degrees. Suppose you have a simple harmonic oscillator,
                then a phase shift of a half period means you get a oscillator which
                exactly cancels the first one. In the case of harmony, the oscillation
                is described with trigonometric functions, so in the simplest case we
                define the period to me 2*Pi (or 360 degrees). A half period would then
                be Pi (180 degrees) - I think you're confused with that case...

                But here, of course, we have no harmonic oscillation, and certainly not
                a period of 2*Pi.

                yours,
                Gerrit.

                Comment

                • Greg Ewing (using news.cis.dfn.de)

                  #9
                  Re: Produce anti-noise

                  Gerrit Holl wrote:[color=blue]
                  > I think a phase shift is measured in time or as a fraction of the
                  > period, not in degrees.
                  >
                  > But here, of course, we have no harmonic oscillation, and certainly not
                  > a period of 2*Pi.[/color]

                  It's perfectly correct to refer to an amplitude inversion as a
                  "phase shift of 180 degrees", even when you're not dealing with
                  a pure sinewave.

                  When electronic engineers talk about phase shifts, they're
                  speaking in the frequency domain, not the time domain. For
                  a non-sinewave signal, a 180 degree phase shift means to
                  decompose it into sinewave components, shift the phase of
                  each component by half of that component's period, and
                  then add the components back together.

                  In the time domain, this corresponds to simply turning
                  the signal upside down, and of course this is how it is
                  usually implemented in hardware. Electronics gurus only
                  describe it as a phase shift because they're used to
                  thinking in the frequency domain all the time (where
                  it's easier to visualise a lot of *other* things that
                  are more complicated in the time domain).

                  So the bottom line is, using a DSP to implement a 180
                  degree phase shift is massive overkill. Just swap the
                  wires to the speaker. :-)

                  --
                  Greg Ewing, Computer Science Dept,
                  University of Canterbury,
                  Christchurch, New Zealand


                  Comment

                  • Josiah Carlson

                    #10
                    Re: Produce anti-noise

                    > So the bottom line is, using a DSP to implement a 180[color=blue]
                    > degree phase shift is massive overkill. Just swap the
                    > wires to the speaker. :-)[/color]

                    That is what I said initially. :)
                    - Josiah

                    Comment

                    Working...