-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchToneDecoder
More file actions
61 lines (48 loc) · 1.2 KB
/
touchToneDecoder
File metadata and controls
61 lines (48 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%touchToneDecoder.m
%Peter Heitkemper
%5-3-21
clear all;
format compact;
clc;
% Change sample location to isolate each digit
% 30,000 total samples/10 digits = 3,0000 samples per digit
% Creating an array and looping through would be next step
% Then writing a method to determine frequency peaks and calculate
% digits automatically.
sample = [27000,30000];
[signal,samplerate]=audioread('PeterHeitkemper.wav',sample);
t=0:1/samplerate:(length(signal)-1)/samplerate;
% signal = signal(1:2500,1)
% t = t(:,1:2500);
% Calculate Fast Fourier Transform of a Signal
Y = fft(signal);
L = length(Y);
% Calculate the DC offset of the signal
A0 = Y(1)/L;
% Calculate Amplitude Spectra
Amp2 = abs(Y/L); % Divide the L and find the magnitude
Amp1 = 2*Amp2(2:L/2+1); % Parse the array and multiply by 2
% Calculate Frequency Array
freq = linspace(samplerate/L,samplerate/2,L/2);
%Amplitude Spectra
subplot(2,1,1)
hold on
stem(freq,Amp1)
xlabel('frequency (Hz.)')
ylabel('Amplitude')
grid on
box on
% Plot the zero line
plot(t,(t.*0),'k')
hold off
subplot(2,1,2);
hold on
%Plot the superpositioned signal
plot(t,signal,'k')
xlabel('Samples ')
ylabel('Signal')
grid on
box on
% Plot the zero line
plot(t,(t.*0),'k')
hold off