Trying to play Sound at random times during elapsed time.
Show older comments
Firstly, my problem is that I cannot seem to have matlab play my sound file at my desired times. I want a pseudorandom array so that I know when the sound was played. However, in its current state,
etime==randomTme %doesnt work
because of the lack of input arguments and when I try to use Pauses, it messes up the audio playing and plays for longer than I want it to. So i am not entire sure how to set my elapsed time equal to the seconds I want.
I have my function
function[y,Fs] = soundFun(fileName)
[y,Fs] = audioread(fileName);
t0 = clock;
randomTime = sort(randi(9,3,1));
while etime(clock,t0) < 20
if etime == randomTime
sound(y,Fs);
end
%sound(y,Fs);
%pause(2)
%sound(y,Fs);
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!