dimanche 21 février 2016

i need help adding a auto play function and also adding a pause in between each file when played

Add the “rng(‘shuffle’)” function call at the beginning of the program “before” the while loop.

Add an input() function call to ask the user to input a string. Press A to select auto play random voices or other keys to manually select voices to play before the while loop.

. Add the if condition to check the user input to be ‘A’ or ‘a’. The if code block contains a call to the randi() function to obtain an integer between 1 and the total number of voice files and save the random number in the same variable used to store the user selected voice number. The if code block will call the randi() function again and obtain another integer between 1-5. The if code block will also call the pause() function to randomly pause the program between 1-5 seconds each time it runs.

loopcounter = 0;
repeat = true;

while repeat
sel = input('Enter your selection:','s');

switch round(str2double(sel))
    case 1
        [y,Fs] = audioread('check_out_whats_new.wav');
        sound(y,Fs);
    case 2
        [y,Fs] = audioread('pacman_death.wav');
        sound(y,Fs);
    case 3
        [y,Fs] = audioread('buy_one_free.wav');
        sound(y,Fs);
    case 4
        [y,Fs] = audioread('t2_hasta_la_vista.wav');
        sound(y,Fs);
    case 5
        [y,Fs] = audioread('irritate_me.wav');
        sound(y,Fs);
    case 6
         [y,Fs] = audioread('about_time.wav');
        sound(y,Fs);
    case 7
        [y,Fs] = audioread('hard_drive_crash.wav');
        sound(y,Fs);
    case 8
        [y,Fs] = audioread('Ms_Pacman_Death.wav');
        sound(y,Fs);
    case 9
        [y,Fs] = audioread('Game-Show-Buzzer.wav');
        sound(y,Fs);
    case 10
        [y,Fs] = audioread('The-Price-Is-Wrong.wav');
        sound(y,Fs);
    case 11
        [y,Fs] = audioread('t2_correct.wav');
        sound(y,Fs);
    case 12
        [y,Fs] = audioread('t2_goodbye.wav');
        sound(y,Fs);
        repeat = false; 
        otherwise
        disp('no valid input');
        loopcounter = loopcounter - 1;
end
    loopcounter = loopcounter + 1;
end

disp('Thank You for Playing!!')

fprintf(['%d loopcouner.\n',sel])

disp(['Total number of files played:', num2str(loopcounter)]);




Aucun commentaire:

Enregistrer un commentaire