Hi guys, noob here.
I want to get a spectrum analysis on my arduino done, or just simply, the pitch of the sounds played.
I have seen a solution, using a microphone:
... but I want to make it without a microphone.
(In short: arduino, using a microphone prepared for use with arduino, reads the input on an analog input, gets with fast fourier transformation the frequency of the input signal, and shows on an OLED screen.)
Simply put, I wired the sound output of my laptop to the analog input of the arduino, and tried the code from the youtube video above ( https://www.dropbox.com/sh/m6c40pu99fqxb5b/AABAQTv67pbYOl6gNozWwDNLa/spectrum?dl=0&preview=spectrum.ino ), but using the FFT (fast fourier transformation), I get wrong results.
After tweaking I got it working, but I don't understand the math at all, and my numbers don't add up. I send out 4500 Hz to the arduino, but get a peak at the 95% of the spectrum analysis, if I raise the pitch on the source (using just 1 sine generator sound), the spectrum "reverses", on 4800->5200->... the peak on the chart moves LEFT. Then at 9000 Hz it turns again, moves to right again, and so on.
I have a 2. peak too, with half of the height of the main peak, at the half frequency of it. Like when 4500 Hz is the peak, I see a half that high peak at 2250 Hz (could be that I misread it).
(I am using a FiiO K1 USB DAC, the volume boost on maximum gets the peak around 60% of the chart. The height of the peak represent the volume rightly, I tested it. The power seems enough.)
Right now I have no other IC or anything, if I can, I don't want to use it first. I have no knowledge of circuit design.
(The code above filters out the 50-60 Hz peak, please check the code for more details. The OLED screen is not the issue here, just getting the fourier transformation and the math right.)
