Go Down

Topic: Reading music from aux without additional circuit (Read 182 times) previous topic - next topic

Tomas10024

I want to make something like this https://youtu.be/lU1GVVU9gLU
Circuit link: https://www.mathscinotes.com/2014/03/a-simple-frequency-to-voltage-converter/
The question is can i do that without any additional circuit (aux to arduino directly) and will that work?

DVDdoug

#1
Jan 14, 2020, 03:45 pm Last Edit: Jan 14, 2020, 08:32 pm by DVDdoug
The guy isn't using a "frequency-to-voltage" converter, which wouldn't work well because normal audio contains multiple-simultaneous frequencies.    I believe he's using an MSGEQ7 which is a "spectrum analyzer" chip.   (The manufacture incorrectly calls it a "Graphic EQ" chip.)

You at-least need a bias circuit (2 equal-value resistors and a capacitor) because the Arduino can't directly read the negative half of the AC audio waveform.   The Arduino can be damaged by negative voltages or the audio can be "damaged" (distorted) during the negative voltage swing.

There are FFT/FHT libraries that you can use to get the frequency information.    But, that's software intensive and if you are going to use NeoPixels the software for that is software intensive too (and memory intensive) and you may find that the Arduino isn't fast-enough or "powerful" enough to do a good job of both at once.

Just to get "off the ground" take a look at my World's Simplest Lighting Effect




------------------------------------------------------------------------------------------------------------
P.S.
If it was me, I'd use the MSGEQ7 chip unless you need more than 7 frequency bands because it's easier than FFT.   But, I've never done anything with frequency.  There are FFT/FHT libraries so you don't have to write all of the code yourself, but there is probably 100 times as much code in the FFT library as it takes to read the MSGEQ7.   


With any project I recommend you work on the input & output separately before putting everything together.  You can choose which one to work-on first.

In your case the input is the audio signal.   You can start with my "World's Simplest..." code and add/build from there.   There are some commented-out "print" statements.  You can remove the '//' comment marks to "see" what kind of readings your are getting.    It's only amplitude ("loudness"), no frequency information but it should be enough to get started.   

And, at the bottom of that post you'll find a schematic for the bias circuit. 

The output is the lights/LEDs.   If you are using a NeoPixel LED strip Adafruit.com has lots of helpful information and sample code so you can make patterns with the LEDs, etc.   

When you understand how the audio input works and how to control your lights/LEDs you can decide how to make the lights react to the sound.

The Audacity Website has a nice introduction to how digital sampling and digital audio works.   You need to understand some of those basics to understand how my "Simplest Effect" works and if you can understand that and how my example is working, you should be able to understand how my simple effect "looses" the frequency information by averaging the amplitude information to find "loudness".

The audacity tutorial doesn't really get into frequency or FFT, and don't confuse the sample rate with the audio frequency.   

They do talk about sample rate.   The sample rate has to be at least twice the audio frequency.  The easiest way to understand that is to realize that you need to sample the top-half of the wave at least once and the bottom half at least once (two readings/samples per "wave"). 

A "proper" analog-to-digital converter should have a low-pass filter to make sure you are not sampling audio above the "Nyquist limit" (half the sample rate), and it has to be an analog filter before the data is digitized.   (All soundcards have the filter.)   Without the filter you can get aliasing (false frequencies).   But, with all of that said,  the highest audio frequencies are usually weak so the aliasing is "weak" and for a visual effect you can get-by without the filter.


You can also use Audacity to generate tones at any desired frequency that you can play on your computer to test how your lights respond to different frequencies.

You may also want to read-up on FFT.   It's some "serious math" but it's helpful if you can understand what it's doing, if not exactly how it works.

Go Up