Back in the early days of Silicon Valley, when bad behavior may have been forgiven a little more readily than it is today, a legendary engineer named Bob Widlar was so intolerant of defective parts and malfunctioning prototypes, he was in the habit of destroying them with a sledge hammer. This came to be known as "widlarizing" them. He also had a strong dislike of ambient noise, and built a device known as "the hassler" which worked by fighting sound with sound. If someone shouted at Widlar, the hassler kicked in and emitted a piercing shriek of protest. I'm going to suggest a circuit that you can build for under $15 which will do what the hassler used to do, although I'll be referring to it here as a Noise Protest Device.
Widlar wasn't interested in digital chips that use the 0s and 1s of binary code. Supposedly, he used to say that "every idiot can count to 1." He created analog designs, where the great challenge has always been to make an accurate, amplified copy of a rapidly fluctuating input signal. Many of the early operational-amplifier designs were pioneered by Widlar, and thus it seems appropriate that my Noise Protest Device uses an LM741, one of the oldest and most widely used op-amps.
The basic concept of fighting sound with sound creates an obvious paradox. If a Noise Protest Device reacts to ambient noise by making more noise, it will trigger itself, creating an endless feedback loop.
One solution to this problem would be an audio filter on the microphone input, so that the Noise Protest Device can't hear itself but will still hear someone shouting. I like this idea, but I don't know enough about designing audio filters to be sure of making it work.
An easier solution is simply to limit the duration of the protest output to, say, a couple of seconds. Then there can be a momentary pause while the output is suppressed. At the end of the pause, the Noise Protest Device starts listening again, and if someone is still shouting, the cycle will repeat.
The flow diagram above illustrates this concept. An electret microphone, which will cost maybe $1, is wired to the input of the op-amp, which amplifies the voltage. A transistor allows the voltage to be adjusted. A capacitor smooths the signal sufficiently to trigger a timer that I call the Noise Duration Timer. This sends power to an off-the-shelf noise maker such as a beeper–or maybe a burglar alarm siren, which would really get people's attention. A beeper will cost maybe a couple of dollars, while a siren will be closer to $10.
When the Noise Duration Timer reaches the end of its period, its output will go low, which will shut down the noise output. The transition also triggers a second timer, which I call the Pause Duration Timer. This will inhibit the circuit from responding to any ambient sound for a brief period.
The electret microphone is at the top-right corner of the schematic. This device has an open-collector output, which means it contains a transistor whose collector drives the rest of the circuit. After passing through the 0.68uF capacitor it induces little variations above and below the midpoint voltage established by two 68K resistors.
The op-amp amplifies these variations, but its behavior is controlled by negative feedback–a very important concept in the world of audio amplifiers. The 4.7K resistor labelled "A" in the schematic sets the negative feedback in conjunction with a 1 meg potentiometer. If the value of the resistor is reduced, the output from the op-amp goes up, and vice-versa.
A 2N2222 transistor passes the signal through to the input of the Noise Duration Timer, labelled "B" in the schematic. Its output from pin 3 goes through a 220-ohm resistor to an LED, labelled "D". This is just for demonstration purposes. Once you have the circuit working, you can substitute a beeper for the LED, or you can use a relay to trigger a siren. An optocoupler would be even better than a relay, as it can isolate the siren from the sensitive circuit containing the LM741.
While the Noise Duration Timer is running, its output is high. At the end of its cycle, the output goes low. This transition passes through a 0.1uF coupling capacitor, triggering the Pause Duration Timer. The output from this timer lights a second LED, which again is just for demonstration purposes and can be removed once the circuit is working.
The output from the Pause Duration Timer goes through another transistor, at the bottom of the circuit, which is used to pull down the voltage on the reset pin of the Noise Duration Timer (labelled "C"), suppressing that timer so that it will not respond to any sound input until the end of the pause.
When you have finished wiring the circuit, apply power. The initial power surge may activate one timer or the other. You can ignore that.
To check that the timers are working, briefly ground pin 2 (the trigger pin) of each of them. This should make the LED light up in each case. You can also use your meter to verify the input voltage on the trigger pin of the first timer.
Now make a noise into the electret microphone. A steady "Ahhhh" sound works best, but you can shout abuse at your Noise Protest Device if you prefer, and this may be more satisfying if you've been having trouble getting it to work. Either way, sustain the sound for as long as you can.
There may be an initial hesitation. Then you should see the first LED light up for approximately two seconds. Imagine that its output is activating the protest output. Then that LED goes out, and the second one comes on, to tell you that the Pause Duration Timer is inhibiting the Noise Duration Timer. You can continue making as much noise as you like, but the Noise Duration Timer will ignore it, and its LED will stay dark, until the Pause Duration Timer has completed its cycle.
You'll probably want to tweak the circuit to match your noise environment. If the 1 meg potentiometer won't make the circuit sensitive enough to please you, try substituting a 3.3K resistor for the 4.7K resistor labelled "A".
The 470-ohm resistor labelled "E" controls the voltage from the transistor to the Noise Duration Timer. If that timer isn't triggered reliably, you can try values higher or lower than 470 ohms.
The 100uF electrolytic capacitor labelled "F" is necessary to smooth the AC signal which passes from the op-amp and through the transistor. However this capacitor does take a second or so to charge. While it is charging, the Noise Duration Timer won't respond. This simply means that there is a short delay from the moment when someone starts shouting, to the moment when the protest output begins. Similarly, when someone stops making noise, the capacitor takes a second to discharge, so you may get one additional protest output cycle.
Personally I like this behavior, because the circuit gives the shouting person a brief grace period in which to behave, but once the circuit decides that he's going to keep on shouting, it adds an extra cycle just to make sure that he's got the message.
If you prefer a more immediate response, you can substitute a 47uF smoothing capacitor. This may cause the Noise Duration Timer to retrigger itself spontaneously, because the smaller smoothing capacitor is allowing more voltage spikes to get through. You can stop the retriggering by backing off the 1M potentiometer a bit. This should still allow a reasonably sensitive response.
The power supply that you use may affect the performance of the circuit to some extent. A 9V battery will take longer than a bench-top power supply to charge the 100uF capacitor, and the circuit may seem a little less sensitive. Here again, if the 1M trimmer doesn't provide you with enough range, you can always increase the sensitivity by reducing the value of the 4.7K resistor labelled "A".
I used the plastic-packaged version of the 2N2222 transistors. If you use the metal-can version, they have slightly more amplifying power, and you may have to adjust the 470-ohm resistor labelled "E".
I didn't have any problems with the circuit starting to oscillate, but if you do, try increasing the value of the 100uF capacitor labelled "F".