Fourier Transformation of a portion of an audio signal is only resulting in a horizontal line, why?

6 views (last 30 days)
I am attempting to deconstruct / analyze a song to better understand the nature of music. I have been referencing this link ----> I am currently trying to identify two seperate singers in the song by there frequency patterns. I have successfully created a time series of a portion of the song where both singers are singing together on a lyrical verse. The trouble is that when I attempt to fourier transform the time series signal into its frequency components, I get a horizontal line across the frequency domain. I should obviously be getting a series of vertical spikes. Attached below is my resulting plot and the code I am running. I believe the problem stems from the power of the DFT and or the frequency range variables, but I can't for the life of me find a solution, after close analysis of my variables. Thank you in advance for the assistance.
Filename: 'C:\Users\nutri\Documents\cMATLAB\Music Analysis Project for 690\volume_bend_stripped.wav'
CompressionMethod: 'Uncompressed'
NumChannels: 2
SampleRate: 44100
TotalSamples: 11842560
Duration: 268.5388 seonds
Title: []
Comment: []
Artist: []
BitsPerSample: 16
folder = 'C:\Users\nutri\Documents\cMATLAB\Music Analysis Project for 690';
baseFileName = 'volume_bend_stripped.wav'; % Include extension
fullFileName = fullfile(folder, baseFileName);
[y, Fs] = audioread(fullFileName); % Read into array
d = audioinfo(fullFileName);
%audiotxt = load("volume_bend_stripped.txt");
% sound(y, Fs); % Play it
n = length(y); % Sample Size / Magnitude
wrkingsize = 11842560 - 7822; % remove zero value samples
% Fs = 44100; % Sample Frequency / Sample per Second
mfs = Fs/2; % Meaningful Frequency
t = (0:n-1)/Fs; % Time Range for Data
dt = 1/Fs; % Time Increments per Sample
F = fft(n); % Discrete Fourier Transform
a = abs(F); % Amplitude of DFT
f = (0:n-1)*(Fs/n); % Frequency Range
pF = (abs(F).^2)/n; % Power of the DFT
% Both singers singing between 40 - 44 seconds
f1 = figure('Name','Full Range','NumberTitle','off', 'Color', [0.85 0.85 0.85]);
% Distinguish Frequencies between Singers
r = y(1764000:1940400);
R = length(r);
u = pow2(nextpow2(R)); % Transform length
ffR = fft(R,u); % Fourier Transform
%fR = (0:R-1)*(Fs/R); % Frequency Range
fR1 = (0:u-1)*(Fs/u); % Frequency Range
pFR = abs(ffR).^2/u; % Power of the DFT
tR = ((dt*(Fs*40)):dt:(dt*(Fs*44))); % Time Range from 40sec to 44sec
tR1 = (0:dt:(R-1)/Fs); % = tR
p4 = plot(tR,r,'m');
xlim([min(tR)-0.1 max(tR)+0.1])
xlabel('time (s)'), ylabel('Amplitude')
grid on
set(gca,'GridColor','k','LineWidth', 1, 'Color', [0.9 0.9 0.9])
p3 = plot(fR1, pFR, 'b');
%xlim([dt*(Fs*40)-1 dt*(Fs*44)+1])
xlabel('Frequency'), ylabel('Power')
grid on
set(gca,'GridColor','k','LineWidth', 1, 'Color', [0.9 0.9 0.9])

Accepted Answer

Star Strider
Star Strider on 19 Nov 2022
R = length(r);
u = pow2(nextpow2(R)); % Transform length
ffR = fft(R,u); % Fourier Transform
%fR = (0:R-1)*(Fs/R); % Frequency Range
fR1 = (0:u-1)*(Fs/u); % Frequency Range
pFR = abs(ffR).^2/u; % Power of the DFT
p3 = plot(fR1, pFR, 'b');
Here, ‘R’ is a scalar, so a constant, and since it has no variation with respect to time (all scalars that I’m aware of don’t vary) its Fourier transform is also a constant. The plot of it is correct.
I suspect that you intended to take the fft of something else.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!