473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Jul 18 '05 #1
9 3326
> 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.


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
Jul 18 '05 #2
In article <bv*************@news.t-online.com>, Diez B. Roggisch wrote:
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.


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.


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.

Jul 18 '05 #3
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
Jul 18 '05 #4
> 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.


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

Regards,

Diez
Jul 18 '05 #5
> 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.


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
Jul 18 '05 #6
>>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.

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


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
Jul 18 '05 #7
Josiah Carlson wrote:
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?


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.

Jul 18 '05 #8
Gerrit Holl wrote:
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.


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
http://www.cosc.canterbury.ac.nz/~greg

Jul 18 '05 #9
> 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. :-)


That is what I said initially. :)
- Josiah
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jason | last post by:
Hi guys, I am having problems with VML. I had been working on a problem for sometime now, and I just recently discovered what the problem really was: VML was anti-aliasing my rectangles, but I...
7
by: Maxim Shemanarev | last post by:
I'd like to announce my project called Anti-Grain Geometry. http://www.antigrain.com Anti-Grain Geometry (AGG) is an Open Source, free of charge graphic library, written in industrially standard...
17
by: rgoya | last post by:
Peace be with you! About a year ago, I created a JavaScript which turns any web site into an online anti-war protest: http://www.geocities.com/rgoya/javascript/PROTEST.HTM I have recently...
3
by: Michel | last post by:
Is there a way I can anti-aliasing a gif to be able to get a hi-quality resizeable backgroundpicture. When a GIF of JPG is being resized by the browser you get wurse pictures because it needs a...
6
by: bissatch | last post by:
Hi, I want to display text on screen with anti aliasing to make it appear smoother. Is it possible to do this in browsers by perhaps applying a style to it or is it entirely up the the browser?...
22
by: Martin Eyles | last post by:
Hi, I have some text on a page in a small font. The font size has been OK in other applications, but in a web browser, the legebility suffers due to the anti-aliasing. Is there a way to turn off...
10
by: Manfred Braun | last post by:
Hi All, I am writing a proggi, which should monitor some processes. While doing this, I needed a test-program and wrote one, which does nothing else than to consume some cpu, sometimes more,...
4
by: Mike | last post by:
Hi, I took an interest a few months ago in an anti framebreaker javascript. All my research told me that it was impossible. If a website is loaded into a frame/iframe then if it has frame...
2
by: adam.timberlake | last post by:
I was following an article on a website earlier, and although it outputted the pie chart for me perfectly, I want to make it anti- aliased somehow. I have linked to the specific article below just...
6
by: Roderik | last post by:
Hi, On my website I implemented tooltip alike layers when you hover the category items in the sidebar on the right. See: http://www.roderik.net/ The layers that become visible have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.