To begin the project, the first step is deciding what song you want your filter to work best with. This can be done by using an audio file frequency spectrum displayer. I decided to use Academo - Spektrum Analyzer. You can find most song MP3's for free conversion software. I got the easiest results using a free YouTube video to MP3 converter - Y2Mate - YT to MP3. For this project I chose to use the song 'SWIM' by Mild Minds. The output will be as follows:
Project song choice - SWIM
Example spectrum analyzer output from the song.
From the above spectrum chose three major frequencies you would like to highlight. I went with:
High frequencies > 14.3 kHz | Midrange frequencies ~ 5.1 kHz | Low frequencies < 100 Hz
There are several analog filter combinations and configurations that would achieve the goal of isolating the desired song frequencies. Depending on your uses and level of band quality needed for your circuit, you may need to use different filter configurations than I did.
Isolating high frequencies: Active bandpass filter
Midrange frequencies: Active bandpass filter
Low frequencies: Lowpass filter
The standard audio jack supplies an AC voltage with a 1 volt RMS value. For the purposes of this project, we will assume our voltage source to supply 1 volt RMS at varying frequencies.
To complete this project we will need 4 separate elements as seen below:
From our research, we found that the standard audio-jack supplies approximately 1-Volt RMS. If you wish to power a speaker in the circuit you want a voltage output of ~ 2.5-Volts RMS. Given these restraints we determined that we want a preamplifier circuit with a gain of K = 2.5.
To achieve this a standard inverting op-amp circuit can be used to increase the voltage output. Inverting the signal of a sound file does not change the audio quality so there is no issue in an inverting op amp configuration.
Image courtesy of ElectonicsTutorials
Since we want a gain value of 2.5, we selected resistor values of R_f = 25 kΩ and R_in = 10 kΩ .
Circuit pre-amplifier modeled in LTSpice.
For simplicity, we are modeling using ideal op-amps that do not require power in the simulation. In a real construction it is critical to remeber to power your op-amp to above the range it is amplifying too. for this project I would recomend powering all op-amps with +5V and -5V to the respective power rails.
In the simulation output you can see an amplification of ~8 dB which corresponds to our calculated magnitude gain of 2.5x.
Simulation output
The blue line shows the voltage output at the exit of the op-amp.
The green line shows the voltage input at the voltage source.
Since our input voltage is 1-Volt RMS, this gain will give us our desired voltage output of 2.5-Volts RMS.
The first goal frequency to isolate is the > 14.3 kHz range. We are using an active bandpass filter to do this to eliminate false signals from high frequency noise.
As the goal of this project is to explore different filter configurations in practical applications I will be using a different filter configuration than the second active bandpass filter that will be used in block #2. For this filter we will use a cascaded filter configuration.
To find the transfer function of a cascaded filter, you simply find the transfer function of each individual filter and multiply them together. The individual circuit configurations I decided to use are as follows:
Passive high pass filter:
Given the equation f_c = 1 / (2*PI*R*C), I selected component values of R = 13 kΩ and C = 1 nF giving a low cut off frequency of 12.242 kHz.
Passive Low pass filter:
Given the equation f_c = 1 / (2*PI*R*C), I selected component values of R = 10 kΩ and C = 1.06 nF giving a high cut off frequency of 15.015 kHz.
Theoretical center frequency:
The center frequency can be found by finding the square root of the product of the lower and upper cut off frequencies. Using this formula we can find a theoretical center frequency of 13.558 kHz. This is the most critical value of the filter and what we will aim to verify through analytical and simulation analysis.
Inverting op-amp:
Since the goal of this project is to cause an LED to light up when the chosen frequencies are being supplied from the supplied audio source, we want an output voltage of between 2 and 3 volts RMS from the filter. To find the amplification needed to achieve this I simulated the circuit with various op-amp gains with the LED connected until the output voltage reached ~ 8-9 dB. The values that gave this result were R_f = 55 kΩ and R_in = 10 kΩ and therefor a gain value of 5.5.
To find the full block output I would recommend using MATLAB to multiply the various transfer functions together.
We can then plug in the values to generate a Bode plot of the filter and analyze how it will work in our circuit:
When generating the bode plot of the full transfer function we achieve a center frequency at nearly the exact point we want to isolate in the frequency analysis (13.575 kHz). It is notable that the lower and upper cut off frequencies are further to either side than we initially calculated but this is expected with the cascading filter configuration. Other filter configurations are able to generate a higher quality band but this filter will still work well for our purposes.
LTSpice ciruit schematic for filter #1:
Bode plot generated through circuit simulation:
When generating a bode plot for this filter we find a center frequency that aligns exactly with our calculated and MATLAB center frequency values at 13.5 kHz. Depending on the frequency that you are trying to select in your analog frequency analyzer, your bode plot will likely be shifted either left or right.
Here we can also see that at the center frequency supplies a voltage with a magnitude of 8.0742 decibels. Since the input voltage is 1-Volt RMS this correlates to an output voltage along the LED (D3) of 2.532 volts RMS. This is perfectly in range to adequately power our LED at our selected frequency.
We have now verified that filter #1 works correctly with our circuit set up and will give us our desired response.
Our next goal is to isolate the mid range frequencies at ~ 5.472 kHz. In an effort to explore how different filters act in a circuit we are going to use a different bandpass circuit configuration than the previous filter.
Transfer function calculation:
f_c1:
Given the equation f_c1 = 1 / (2*PI*R1*C1), I selected component values of R1 = 3 kΩ and C1 = 10 nF giving a low cut off frequency of 5305.16 Hz.
f_c2:
Given the equation f_c2 = 1 / (2*PI*R2*C2), I selected component values of R2 = 6k kΩ and C2 = 4.95 nF giving a high cut off frequency of 5358.75 Hz.
Gain:
The gain of the filter is given by K = - R2/R1 = -2. This gain allows for the filter to directly supply enough voltage to power the LED in the circuit.
Center frequency:
From the above two cut-off frequencies we can calculate a center frequency of sqrt( f_c1 * f_c2 ) = 5.33 Hz. You may have different values depending on the frequencies you are trying to isolate. Again this value is the most important value for our filtering project so we will aim to verify it using MATLAB and simulation.
Here we can see that the MATLAB simulation using our calculated transfer function works as expected and provides a center frequency of 5.34 kHz. This center frequency is very close to our desired sleceted frequency from the initial MP3 frequency spectrum analysis.
Mid-range frequencie bandpass filter schematic in LTSpice:
LTSpice circuit simulation output across LED
In this LTSpice bode plot we can see that our theoretical center frequency is almost perfectly emulated by our circuit simulation. In the simulation we find a center frequency of 5.31 kHz with a magnitude of 8 dB.
The 8 dB output means that the LED is being supplied with ~ 2.5 volts RMS. This is the ideal operating range of a standard LED so we can expect filter #2 to also work as expected in our circuit. Depending on the components you use the output may be higher or lower so you will need to adjust the op-amp gain and other filter values accordingly until you achieve an 8 dB output.
To isolate the selected low frequencies of our song ( < 100 Hz ), we will use a lowpass frequencies. If you want to exclude certain low frequencies you can implement another bandpass filter but this is not strictly necessary for our project as we don't have to worry about extraneous noise below 0 Hz.
As previously shown the transfer function and cut-off frequencies for a passive low pass filter can be found as the following:
This is the simplest filter of the three and requires only two components
From the equation f_c = 1 / (2*PI*R*C) I selected R = 100 Ω and C = 10 µF. These values give a cut off frequency of ~159.15 Hz.
These values are arbitrary and you may use any values that you would like to achieve your desired cut-off frequency.
Transfer function set up in MATLAB
Bode plot from transfer funtion:
From the MATLAB bode plot we can validate our transfer function by seeing that our calculated transfer function aligns with the -3 dB frequency. Now that MATLAB has verified our calculations we can simulate our circuit in LTSPICE and analyze the response. We don't have to worry about the low decibels in this bode plot as in our full circuit our input signal is pre-amplified in block #1.
LTSpice circuit schematic:
LTSpice simulation output across LED:
In the simulation, you can find the cut-off frequency by placing the cursor on the maximum magnitude value and movie until you get to max(mag_dB) - 3 dB. In our simulation the maximum magnitude was at 8 dB and the cut-off frequency at 5 dB is shown to be 157.04 Hz. This aligns with both our hand calculations and MATLAB simulation.
Furthermore, the 8 dB magnitude relates to a voltage value of 2.5-Volts RMS which aligns with the operating conditions of a standard LED and demonstrates that an op-amp is not needed in this section of the filter.
Full analog frequency analyzer circuit with LED indicators:
Note: None of the op-amps are powered in the simulation due to my use of ideal universal op-amps in LTSpice. In a real circuit configuration each op-amp would need to be powered to +5V and -5V to prevent clipping.
Note: I also added a op-amp voltage follower loop in the intersection of my three filters and pre - amp circuits. This may not be strictly necessary but caused my resulting LTSpice bode plots to come out signficantly mroe accurate to my numerical calulcations. If you find your results are not aligning with your theoretical values consider adding it to your circuit and testing its effect!
Block diagram overlay:
Resulting bode plot across LEDS for three filters:
Zoomed in look at filter responses: V(n011) = Voltage input magnitude, V(n009) = Pre-amplifier output
Congratulations! You have successfully created an analog frequency analyzer using passive and active filters. The more prominent your selected frequencies are in the input signal the brighter that corresponding LED will be in your built circuit.
This design is scalable for as many or as few frequencies you want to select, just add more blocks!
If you wish to recreate my exact circuit I have provided a spread sheet with all of the component values for the full circuit as well as locations to buy each resistor and capacitor. By combining resistors/capacitors in series/parallel you are able to create all of the values I used from the linked variety packs: