gpt4 book ai didi

matlab - 如何使用 Matlab 在特定时间间隔播放音频文件?

转载 作者:太空宇宙 更新时间:2023-11-03 20:13:58 26 4
gpt4 key购买 nike

正常情况下:

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]) 指定开始停止功能:

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);

关于matlab - 如何使用 Matlab 在特定时间间隔播放音频文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33654323/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com