Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

how to play sound one after the other depending on the number inputed

1 view (last 30 days)
prompt = 'Enter atleast 10 numbers: ';
str='0';
while length(regexp(str,'\d'))~=10
str = input(prompt,'s');
end
N=length(str);
count=1;
for k=1:N
m=str2double(str(k));
if isnan(m)==0
str(count)=k;
count=count+1;
numbers = cell2mat(sscanf((str),'k'))
disp(m)
end
end
%sound 1
fs=8192;
T=.5;
t=0:(1/fs):T;
y1=cos(2*pi*1209*t)+cos(2*pi*697*t);
sound(y1,fs);
pause(.5);
%sound 2
fs=8192;
T=.5;
t=0:(1/fs):T;
y2=cos(2*pi*1336*t)+cos(2*pi*697*t);
sound(y2,fs);
pause(.5);
%sound 3
fs=8192;
T=.5;
t=0:(1/fs):T;
y3=cos(2*pi*1477*t)+cos(2*pi*697*t);
sound(y3,fs);
pause(.5);
%sound 4
fs=8192;
T=.5;
t=0:(1/fs):T;
y4=cos(2*pi*1209*t)+cos(2*pi*770*t);
sound(y4,fs);
pause(.5);
%sound 5
fs=8192;
T=.5;
t=0:(1/fs):T;
y5=cos(2*pi*1336*t)+cos(2*pi*770*t);
sound(y5,fs);
pause(.5);
%sound 6
fs=8192;
T=.5;
t=0:(1/fs):T;
y6=cos(2*pi*1477*t)+cos(2*pi*770*t);
sound(y6,fs);
pause(.5);
%sound 7
fs=8192;
T=.5;
t=0:(1/fs):T;
y7=cos(2*pi*1209*t)+cos(2*pi*852*t);
sound(y7,fs);
pause(.5);
%sound 8
fs=8192;
T=.5;
t=0:(1/fs):T;
y8=cos(2*pi*1336*t)+cos(2*pi*852*t);
sound(y8,fs);
pause(.5);
%sound 9
fs=8192;
T=.5;
t=0:(1/fs):T;
y9=cos(2*pi*1477*t)+cos(2*pi*852*t);
sound(y9,fs);
pause(.5);
%sound 0
fs=8192;
T=.5;
t=0:(1/fs):T;
y0=cos(2*pi*1336*t)+cos(2*pi*941*t);
sound(y0,fs);
pause(.5);
this is my whole code and I'm having trouble figuring out how I can get one sound to play after the other depending on what the user inputs so if the user inputs: 4560987321 then I want it to play the sounds in order (y4,y5,y6,y0,y9,y8,y7,y3,y2,y1) thank you!

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!