2 microphones to Arduino to 1 speaker

Hi Community,
I am planning to build a house intercom with three stations. Each will be equipped with a microphone (with amplifier) and a speaker (with amplifier). I want to run the signals through my Arduino (preferably mini pro or -if bigger resources required- my Arduino due).
Would mean, I take two microphone signals (from mic-shields) into analog in, merge them (which is my first problem) and then send it out to an amplifier via PWM (where I have seen several examples but am not understanding, what's going on).
So - is there someone out there who can help me with that, give me some hint, has doen something similar before?

  1. How to I "summarize" two analog audio-signals (oro even three in case there comes the day, when I want to do a recording)?
  2. Does someone have the audio/physical knowledge to explain, what's going on when I create an audio signal with PWM? -ah and now even a third one:
  3. Is there a rule of thumb what resistors/capacities are required between Arduino and Mic as well as Arduino and Speaker/Amplifier.
    Looking for HELP! :cry:
    :disappointed_relieved:
    Tobias

You're probably not gaining anything by using digital. In general the tricky thing is clocking the audio in-and-out at a constant rate while tying to run the rest of your program. (i.e. Soundcards have their own clock and input/output buffers so the CPU can multitask.)

and then send it out to an amplifier via PWM (where I have seen several examples but am not understanding, what's going on).

Since the Due has a DAC, you can use "normal" PCM. (If you don't know how that works, the [u]Audacity website[/u] has a good introduction to how audio is sampled & digitized.

...merge them (which is my first problem)

...1. How to I "summarize" two analog audio-signals

Audio mixing is done by addition (summation). Analog mixers are built-around [u]summing amplifiers[/u]. You mix digitally by summing the samples. i.e. Sample 1 from microphone A + sample 1 from microphone B = output-sample 1, etc. (44,100 samples per second in the case of CD audio.)

But, you do usually have to scale the data... If you are adding a 12-bit sample to another 12-bit sample you get a number that's too big to send to your 12-bit DAC. So in reality, its more of an averaging process (i.e. divide the samples in half before summing). In the real world, it's often a weighted average because all of the audio inputs have their own volume control and they are not necessarily mixed/summed equally. (Most audio editing/processing software uses floating-point so you don't have to worry about bit-depth except at the input/output.)

  1. Is there a rule of thumb what resistors/capacities are required between Arduino and Mic as well as Arduino and Speaker/Amplifier.

Line level inputs are typically 10K - 100K. The line inputs on a soundcard or the input to your powered computer speakers are usually in that ballpark.

A series DC blocking capacitor makes a [u]high-pass filter[/u] (DC is zero Hz so it's blocked by a high-pass filter). Given a 10K typical minimum impedance, 1uF is a typical capacitor value to block DC while allowing the lowest audio frequencies through.

Note that if the microphone shield is biased you do NOT want a capacitor because you do not want to block the bias. If the shield's output is not biased, you need to add a
[u]bias circuit[/u] because the Arduino can't read the negative-half of the AC audio signal.

You should add a series capacitor keep the Arduino's bias out of the amplifier. (And, you do need an amplifier because the Arduino can't directly drive a speaker.)

(oro even three in case there comes the day, when I want to do a recording)?

To record digitally, you simply save the samples in an array or in a file. (Usually in a file, since even at a low sample rate of 8kHz, there are 8000 samples per second.)

Thank you so much, DVDdoug, for your great explanations!
This enlightens my situation a lot.
I first want to try it with the pro mini and see how far I get (space is an issue...). I will also need three microphone addings, so the two DAs from the due would anyhow not be enough (or can I multiplex them to different pins...anyhow).

  • One of the main questions was, how I can merge two audio signals. This is resolved and I understood, that I can simply add both signals and divide by 2 (if I do not need the signal fine tuned).
  • The second was around creating audio with PWM. What I now understood is, that I can take the PWM signal as an emulator for the analog value, nothing more (I was close to thinking, that we do some frequency modulation :-/ which caused my brain to receive its limits :)).
  • Thanks for the rule of thumb regarding low pass filtering! It already works (even without amplifier, but at very low volume).
    However I have had some problems creating the test-sound with another arduino (over PWM) and the new input has some PWM frequency left :slight_smile: which is a beep-overlay. Probably not the perfect low pass filtering constellation yet.
    And again - thanks a lot for your great support, DVDdough!!