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

9 visualizaciones (últimos 30 días)
I am attempting to deconstruct / analyze a song to better understand the nature of music. I have been referencing this link ---->https://www.mathworks.com/help/matlab/math/basic-spectral-analysis.html. 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
%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% WAVE FILE PORTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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]);
tiledlayout(2,1)
x0=300;
y0=150;
width=950;
height=600;
set(gcf,'position',[x0,y0,width,height])
% 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
nexttile
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])
nexttile
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])

Respuesta aceptada

Star Strider
Star Strider el 19 de Nov. de 2022
Consider:
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.
.
  5 comentarios
JAMES DYESS
JAMES DYESS el 22 de Nov. de 2022
I must apologize, I just came to understand what you were saying and what I was doing wrong. I was calculating the fft of the scalar R, when I was meant to calculate the signal range ' r '. After replacing R with r, the result is a proper frequency domain. Thanks for the help.
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Signal Processing Toolbox en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by