I was toying around with an idea for a digital musical instrument with breath control. I've successfully experimented with pressure sensors and they are probably the right way to go, but my first idea was just using a plastic sealed microphone. I never got very far with it, but I think it still has potential for the kind of response I want.

The idea was that a stream of air directed to the hit the microphone would generate white'ish noise (just thinking blowing on a mic) and I could use the loudness of this noise to create the ADSR envelope for my sound. Covering the mic with plastic sheeting still allows this to work and protects it from the moisture in your breath.

However, most of my electronics experience is digital (from discrete digital in college to microcontrollers now) and I'm more of a programmer. I got as far as looking at the noise signal on my 'scope and verifying that it had the characteristics I wanted (to use the smoothed, positive magnitude of the noise as the loudness of the synthesized tones) and I know that if I can get it to a wide enough analog range I can use an ADC to get a digital magnitude. What I lack is the analog knowledge to take the noise waveform and transform it to a varying analog signal representing the average positive magnitude at a fairly high sampling rate.

Any ideas or links to get me started?

I won't really know which answer is totally correct until I get do some experimentation, but the responses have been great so far. The VU meter is pretty close that what I need and the reminder that loudness is logarithmic is useful as well.

It may have been easier to state my problem this way: I want to control a digital tone (either generated or via MIDI) where the "loudness" of the tone is proportional to the intensity of the sound generated by blowing on the mic if that makes any more sense.

  • \$\begingroup\$ Can you post a screenshot (or drawing) of your scope trace? This is a very different question if you're working with near sinusoids or signals with high spikes. If it's just a sinusoid, simply amplify it and run it through a bridge rectifier, outputting to a small cap and a drain resistor to get a nearly DC signal. \$\endgroup\$ – Kevin Vermeer Sep 29 '10 at 21:14
  • 1
    \$\begingroup\$ Related: electronics.stackexchange.com/questions/4208/… \$\endgroup\$ – endolith Sep 29 '10 at 21:39

Loudness is roughly correlated to RMS amplitude, not to peak amplitude, so you need to

  1. sample the input regularly, recording the samples to memory
  2. take a chunk of samples and square each
  3. take the average of all the resulting values
  4. square root

You can probably simplify this depending on how much accuracy you need.

Oh wait, you want analog output. You can put the wave through a precision rectifier (schematics) to get the absolute value, and then filter with an RC filter to get its envelope, as in the circuitry leading to pin 5 of this schematic. Instead of that IC, pin 5 would be your micro's ADC. It's not RMS, but it will show you approximate loudness. This is how most VU meters work.

  • \$\begingroup\$ Well ultimately I want digital output, so that might work. I was just concerned about the required sampling rate. \$\endgroup\$ – cmpalmer Sep 29 '10 at 21:54
  • \$\begingroup\$ If you sample at a lower rate, you'll only be capturing lower frequencies (from DC to half the sampling frequency). If you just want to capture someone blowing into a mic, that's probably good enough, though. \$\endgroup\$ – endolith Sep 29 '10 at 23:19

You'll want a logarithmic amplifier or log amp.

Loudness is measured in decibels; what sounds like a linearly increasing/decreasing loudness to a human being, actually corresponds to exponential changes in acoustic energy.

You can do this by buying off the shelf ICs (e.g. Linear Tech's LT5537). Or you can do it yourself with op-amps, resistors, diodes, and transistors. Transistors have a very nice logarithmic relationship between collector current and base voltage over 5 or 6 decades of current (usually from 10s - 100s of nA to 1-10mA) and can be combined with op-amps to turn a current or voltage in, into a logarithmic voltage out (see this website for a circuit along w/ spiffy waveform graphics). You'll need to have your own waveform-to-RMS detector first, then feed the result into a log amp.

If you don't use a log-amp, you're limited in dynamic range by the resolution + linearity + zero offset of the ADC you use, which may only be 20-30dB.


I recommend you amplify the signal to some level in the range of 0V to 3.3V, and feed this into your microcontroller's ADC. A fairly fast digital signal processor will need to be used. I recommend something like a dsPIC33F. Once you have the analog signal working, the digital side shouldn't be too hard, given your digital knowledge.

  • \$\begingroup\$ So do I just clip the negative side of the signal and then average the maxes as they are sampled, or do I process the signal further before the ADC step? I guess what I'm really looking for is treating the noise as an amplitude modulated signal and trying to extract the signal. Does that make sense? \$\endgroup\$ – cmpalmer Sep 29 '10 at 20:52
  • \$\begingroup\$ It depends how much speed you need. If you directly sample the loudness signal, you can do fancy stuff like RMS calculations, FFT's and you have a higher signal bandwidth, so it can respond to changes quickly. If you filter the signal (such as detecting the peaks) you can use a smaller micro. \$\endgroup\$ – Thomas O Sep 29 '10 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.