My goal is to have dial tones be played for 1 second each with 1 second pauses when the user inputs 10 numbers. I’ve already assigned the tones to variables num1,num2…. I am struggling on how identify the number that is inputted and assign it to the sound and play it with the pauses

clc;clear;

%sound for 1

fs=8192;

T=.5;

t=0:(1/fs):T;

y1=cos(2*pi*1209*t)+cos(2*pi*697*t);

%sound for 2

fs=8192;

T=.5;

t=0:(1/fs):T;

y2=cos(2*pi*1336*t)+cos(2*pi*697*t);

%sound for 3

fs=8192;

T=.5;

t=0:(1/fs):T;

y3=cos(2*pi*1477*t)+cos(2*pi*697*t);

%sound for 4

fs=8192;

T=.5;

t=0:(1/fs):T;

y4=cos(2*pi*1209*t)+cos(2*pi*770*t);

%sound for 5

fs=8192;

T=.5;

t=0:(1/fs):T;

y5=cos(2*pi*1336*t)+cos(2*pi*770*t);

%sound for 6

fs=8192;

T=.5;

t=0:(1/fs):T;

y6=cos(2*pi*1477*t)+cos(2*pi*770*t);

%sound for 7

fs=8192;

T=.5;

t=0:(1/fs):T;

y7=cos(2*pi*1209*t)+cos(2*pi*852*t);

%sound for 8

fs=8192;

T=.5;

t=0:(1/fs):T;

y8=cos(2*pi*1336*t)+cos(2*pi*852*t);

%sound for 9

fs=8192;

T=.5;

t=0:(1/fs):T;

y9=cos(2*pi*1477*t)+cos(2*pi*852*t);

%sound for 0

fs=8192;

T=.5;

t=0:(1/fs):T;

y0=cos(2*pi*1336*t)+cos(2*pi*941*t);

num1=audioplayer(y1,fs);

num2=audioplayer(y2,fs);

num3=audioplayer(y3,fs);

num4=audioplayer(y4,fs);

num5=audioplayer(y5,fs);

num6=audioplayer(y6,fs);

num7=audioplayer(y7,fs);

num8=audioplayer(y8,fs);

num9=audioplayer(y9,fs);

num0=audioplayer(y0,fs);

for ii = 1:10

x(ii) = input('Input a number: ');

end

tt= num2cell(x);

[a,b,c,d,e,f,g,h,i,j] = deal(tt{:});

## 0 Comments

Sign in to comment.