Clear Filters
Clear Filters

Audio signal Frequency Domain plotting symmetrical

19 views (last 30 days)
I have an audio signal m4a thats converted to frequency domain using FFT. The plot I produced ranges from 0-48kHz. From what I understand, the 2 spectrums are not identical. So what I wish to do is to create a plot where the left spectrum is treated as the original values, and mirrored symmetricaly, with the nyquist frequency as the point of reference to mirror.
The left spectrum is what's gonna be controlled. the expected final plot ranges from 0-48kHz. I need to plot a symmetrically mirrored spectrum where if i were to shift the left spectrum to the right, the mirrored spectrum follows to the left, going closer to the nyquist frequenct point. Any values that crosses the nyquist frequency point will be ignored and not shown in the final plot.
  1 Comment
Leonard Gay
Leonard Gay on 6 Jun 2023
Moved: Star Strider on 6 Jun 2023
Referring to the Left Spectrum plot, I am trying to generate an identical one on the right side of the plot. For example now the spectrum looks like it has values from 0-0.75kHz, and the plot ranges to 25kHz (24kHz to be exact based on my Nyquist Frequency). I want to have a plot of the left spectrum, and a symmetrically mirrored spectrum that has the same values as the left spectrum. the final plot will range from 0-48kHz. Just like a mirror, bringing my hand closer to the mirror will bring the reflection closer to my hand, I plan to shift the left spectrum closer to the nyquist frequency point, and the mirrored spectrum will follow suit. however, any part of the spectrum that goes beyond the nyquist frequency point will be trimmed, so they will not appear on the other side. There's more to do afterwards but thats all for now

Sign in to comment.

Answers (1)

Varun
Varun on 17 Aug 2023
Hello!
As per my understanding, you want to produce a symmetrical frequency plot of your audio signal based on the left spectrum of the plot. This can be done as follows:
  1. Using the FFT, obtain the left spectrum of the audio signal.
  2. Calculate N, the length of the left spectrum.
  3. To store the mirrored spectrum, make a new array called mirrored_spectrum with the size of “nyquist_frequency.
  4. In the first N items of mirrored_spectrum”, copy the values from the left_spectrum.
  5. Use the flip function to fill in the mirrored values of the signal in the second half of “mirrored_spectrum.
  6. Plot the mirrored spectrum.
Code Sample:
% Assuming you have the left spectrum stored in the variable 'left_spectrum'
% and the Nyquist frequency is 48 kHz
load gong.mat %Example file
sound(y)
left_spectrum=y;
N = length(left_spectrum);
nyquist_frequency = 48000; % Hz
mirrored_spectrum = zeros(nyquist_frequency,1); %The overall signal is in nyquist_frequency Hz.
mirrored_spectrum(1:N) = left_spectrum; %The starting values are the same as left spectrum.
mirrored_spectrum((nyquist_frequency/2)+1: end)=flip(mirrored_spectrum(1:(nyquist_frequency/2))); %The second half is the reverse of the first half.
plot(left_spectrum)
% Plotting the mirrored spectrum up to the Nyquist frequency
frequencies=(1:1:nyquist_frequency)';
plot(frequencies, mirrored_spectrum);
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Mirrored Spectrum');
You may refer to the following documentation for more information about the “linspace” function: https://www.mathworks.com/help/matlab/ref/linspace.html
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!