Playing random audio from pushbutton
显示 更早的评论
I want to play using gui some .wav files randomly from a certain directory without any repeatition. can anyone help me in this regard?
回答(1 个)
Walter Roberson
2015-12-3
projectdir = '/Users/Snorky/music';
dirinfo = dir( fullfile(projectdir, '*.wav') );
numfiles = length(dirinfo);
order_to_play = randperm(numfiles);
for K = 1 : numfiles
thisfile = fullfile(projectdir, dirinfo(order_to_play(K)).name );
play this file
end
2 个评论
hani ab
2015-12-3
Walter Roberson
2015-12-3
I solved the random order part for you. You need to figure out how to play the file. There are multiple ways described in the MATLAB documentation.
类别
在 帮助中心 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!