Hello,
I am looking to develop an anti-noise speaker. To do this I have a system composed of a perturbation microphone that captures the sound to be attenuated and transmits it to an Arduino due via an adapter. An error microphone captures the result of the attenuation and transmits it to the due also to make a feedback loop. Finally the due is supposed to transmit to the 2nd loudspeaker a sound which would be opposite in phase thanks to a delay with a good amplitude thanks to the feedback of the 2nd microphone.
However I have no knowledge in c++ and arduino. I have a beginning of program which makes the digitization and I think of using an array to make the delay but I do not know how to program it.
Here is my program:
Hello, thank you for your answer.
This project is for school and I have to do the delay by arduino. I made this piece of code this morning but I don't know if it is good
This can sometimes work on low frequencies but otherwise it doesn't work well.
As an experiment, make a mono music file (you can convert an audio file to mono with Audacity). (1) Then, switch the + & - connections to one speaker. When you play the file the bass will be mostly-canceled (2) but the other sounds will just get "weird" because the shorter wavelengths get either canceled or reinforced depending on the different distances between the speakers and your ears. Reflected sounds further complicate things with their "random" time-related phase shifts. At very-high frequencies the waves can be in-phase in one ear and out-of-phase in the other ear!
You'll get better cancelation if you put the speakers close together but it's still imperfect. You'll also get better cancellation outdoors where there are no reflected waves.
Noise cancelling headphones work because the headphone already has some isolation and microphone is very near the ear but it just picks-up the noise, not the mix of original and inverted noise inside the headphone. I believe they are analog and it's just an inversion not a delay.
(1) A true-mono file will play out of both speakers. With Audacity, it's also possible to make a "dual mono" file (the same sound in both channels) and then you can invert one channel in Audacity and you won't have to switch the speaker wires.
(2) With a regular-stereo file, you'll get similar bass cancelation because the bass is usually identical and in-phase in both channels. The vocals (and some other instruments) are usually "centered" too, but those sounds will just get "spacey and weird".
A classic "vocal remover" effect works similarly on digital files (or it can be done electronically). This can very-effective if the vocals are perfectly-centered because you don't have delays of sound traveling through the air or reflected sound waves canceling and reinforcing in the room. Or, if you have a file with identical but out-of-phase left & right channels, they will be canceled to dead-silence if you mix them digitally or electronically but NOT when they are mixed acoustically in a room.