Extract Corresponding Frequency value from the peak amplitude
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have started this code to decode and detect the DTMF character from the wavfile. I am very new to MATLAB and need a urgent help to extract the corresponding frequencies (x-axis) from the peak value (locs) so that i can complete my assignment.
close all;
clear all;
clc;
% Load file, obtain information and play sound
Dialtone = 'DTMFDigit1.wav'; % Input Tone
audioread(Dialtone); %To read the wave file
info = audioinfo(Dialtone);
display(info); % Verify the sudio information
[Dialtone, fs] = audioread(Dialtone); % To obtain the sample rate
sound(Dialtone, fs) % Play Sound
% Plot of the DTMF tone in time domain
N = length(Dialtone); % Obtain total number of samples
idx = 0:N-1;
t = idx*(1/fs);
figure(1);
plot(t, Dialtone) % Plot the signal in time domain
title('Dial Tone Time Waveform'); % plot title3
xlabel('Time'), ylabel('Amplitude'); % plot axis labels
% Plot of the DTMF tone in Frequency domain
n = 2^nextpow2(N); % identify an input length that is the next power of 2
Y = fft(Dialtone,n);
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(n/2))/n;
figure(2);
plot(f,P1)
title("Single-Sided Amplitude Spectrum of Dialtone")
title("Single-Sided Amplitude Spectrum of Dialtone")
xlabel("frequency (Hz)")
ylabel("|P1(f)|")
[pks,locs] = findpeaks(abs(P1),'SortStr','descend','NPeaks',2);
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre DTMF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!