Connect audio from a computer to the Arduino / input audio jack

Hi,

I am rather new to Arduino and electronics.

I want to make one of these cool LED music equalizers and I would like to use FFT on the Arduino. I am aware of MSGEQ7 which seems like an excellent solution but it has only 7 bins and I would like to have more. Also I intend to use a STM32 NUCLEO ARM board that will be hopefully powerful enough for the FFT. No, I do not want to do the FFT on the computer and send the result to the Arduino because this is OS dependent and uses computer resources.

The problem is that I do not know how to send the audio signal to the Arduino. I am afraid serial port won't be fast enough.

  1. Would it be possible to simply feed the stereo headphone jack of my computer to the Arduino ? Just MONO.

  2. There are some microphones for Arduino such as:

https://www.digikey.fr/product-detail/fr/sparkfun-electronics/BOB-12758/1568-1472-ND/6592307

Would it be possible to desolder the microphone from one of the above and solder the line-out of my computer instead of the microphone? This way I will benefit from the amplifier (opamp) and get the signal to the Arduino.

The problem is that I do not know how to send the audio signal to the Arduino. I am afraid serial port won't be fast enough.

Most people use analog.

  1. Would it be possible to simply feed the stereo headphone jack of my computer to the Arduino ? Just MONO.

Yes, and unless your signal is mono you can digitally-sum the left & right channels. (Mixing is done by summation and analog mixers are built around summing amplifiers.)

2.) There are some microphones for Arduino such as:

Electret – amplificateur de Microphone Stable, module MAX9814, contrôle automatique du Gain, MAX4466 | AliExpress
https://www.digikey.fr/product-detail/fr/sparkfun-electronics/BOB-12758/1568-1472-ND/6592307

I have the SparkFun mic. It works OK but it needs slightly-loud sound and there is no sensitivity control. i.e. Louder than I normally listen to the TV. (I normally use a direct connection.*) I just bought it to experiment with.)

There are a few different kinds of microphone boards. The SparkFun version puts-out a biased audio signal, which is what you want for FFT. Some put-out a DC voltage proportional to the loudness and some put-out a logic-one when the volume is above a preset threshold. Some have automatic gain control which you may, or may not, want. (I build automatic sensitivity control into the software.)

Would it be possible to desolder the microphone and solder the line-out of my computer instead? This way I will benefit from the amplifier (opamp) and get the signal to the Arduino.

If you want to pick-up acoustic sounds with the a microphone, I'd recommend buying microphone board rather than "destroying" your computer.

If you want to use headphone-out or line-out, get a [u]Y-Splitter[/u] so you can connect speakers/headphones at the same time. (You won't be able to use the built-in laptop speakers because they cut-off when you plug something in.)

If you use a direct connection you'll need to bias the input at half the supply voltage. Without bias the Arduino can be damaged by the negative-half of the AC audio signal and/or the signal can be "damaged" distorted, and your readings will be distorted without the negative-half of the audio signal and that will totally foul-up your FFT. Since the bias is DC (zero-Hz) you can simply ignore the zero-Hz FFT bin. The standard bias circuit is attached to the bottom of [u]this post[/u].

I want to make one of these cool LED music equalizers

It's actually a spectrum analyzer effect. The MSGEQ7 is mis-named but I guess it's intended to be a visual effect built-into an equalizer.

  • I've made a few sound-activated effects but I've never used FFT. My effects are just loudness or "beat" activated. I'm "thinking about" an MSGEQ7 effect but it will be variations of a color organ/light organ, not a spectrum analyzer.

Sorry I did not explain it well. I wanted to remove the microphone IC from the SparkFun microphone board and put a cable between the board (where the microphone was) and my computer headphone jack. I wanted to reuse whatever is already in the microphone board.

So to get signal from the headphones I need 2 resistors and 1 capacitor. And then try the FFT avoiding a bin that starts around zero.

Thanks!

So to get signal from the headphones I need 2 resistors and 1 capacitor.

Yes. You may need a LITTLE amplification but try the simpler circuit first.

If you want to modify the amplifer, SparkFun publishes the [u]Schematic[/u].

R2 & R3 provide the bias. The gain of an inverting op-amp amplifier is determined by R5/R4. You'll probably want a gain of 5 or 10 so you can lower the value of R5 or put a lower value resistor in parallel with R5.

Remove R1. It's required to power the electret mic and you don't want to "power" whatever you plug-in. :wink:

And then try the FFT avoiding a bin that starts around zero.

I don't know anything about the STM32 NUCLEO, but I'd actually start with the [u]Analog Read Serial Example[/u] to see what kind of raw readings you're getting. (Take out the delay.) That will tell you if you're getting useful readings and you can determine how much gain you want (if any). And, you might want to make some test tones so you can test with a constant signal, and so you can eventually test/debug the FFT/spectrum analyzer.

With the regular 5V Arduino and it's 10-bit (0-1023) ADC, silence should read ~512 (just the 2.5V bias). Otherwise, remember you're reading a waveform that's positive half the time, negative half the time, and that crosses-through zero twice per cycle (that's ignoring the bias). So, your simple readings will "look random" within a range with quiet sound reading slightly above & below the bias and louder sounds deviating more.

Thank you very much for all the explications!!! I am learning.

Two questions:

  1. how is the bottom resistor connected in the standard bias circuit? The triangle at the bottom is ground, but which one:
  • the headphone has ground
  • the Arduino has ground
  • connected to both of them
    ?
  1. Are these the right capacitors: 1uF = 1000 nF
  • ECW-FG1B105J
  • 735P105X9200L (this one is 3 euros)
    ?
    They are not SMD so that I can solder them easily.
    Thanks