像平常一样:
player=audioplayer(snd1,FS1);
play(player);
%let as suppose that sound duration is 10 seconds
% and I wanted to play the sound from second 5 or 7...
% .. depending on the input of user(and using audioplayer libraries)
您可以使用play(playerObj,[start,stop])函数指定start
和:stop
load handel;
playerObj = audioplayer(y,Fs);
start = 1;
stop = playerObj.SampleRate * 3;
play(playerObj,[start,stop]);
或者,您可以计算总数据的子样本并将其提供给audioplayer:
load handel;
% y = data
% Fs = frequency = number of datapoints per second
% so calculate begin and end time using the sampling frequency:
totalTime = size(y,1)/Fs; % all data divided by sampling frequency
beginTime = round(5*Fs); % 5 seconds
endTime = round(7*Fs); % 7 seconds
% playing full audio:
% player = audioplayer(y, Fs);
% play(player);
% playing only part of audio:
player = audioplayer(y(beginTime:endTime,:), Fs);
play(player);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句