Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 概念问题-在wav开始/结束时修剪“沉默”_Matlab - Fatal编程技术网

Matlab 概念问题-在wav开始/结束时修剪“沉默”

Matlab 概念问题-在wav开始/结束时修剪“沉默”,matlab,Matlab,我需要通过修剪文件开头和结尾的相对静默来计算wav文件的长度,然后以毫秒为单位返回持续时间。我知道您可以找到wav文件的持续时间: [w,fs] = wavread('file.wav'); length = length(w)/fs; 我的逻辑是使用波形矩阵左通道的第一列,获得任意阈值,然后通过示例窗口遍历矩阵。如果这些窗口的最大值大于阈值,那么我开始在那里计算时间。当这个窗口的最大值小于这个值时,我停在那里。这就是我到目前为止所做的: %Just use the first column

我需要通过修剪文件开头和结尾的相对静默来计算wav文件的长度,然后以毫秒为单位返回持续时间。我知道您可以找到wav文件的持续时间:

[w,fs] = wavread('file.wav');
length = length(w)/fs;
我的逻辑是使用波形矩阵左通道的第一列,获得任意阈值,然后通过示例窗口遍历矩阵。如果这些窗口的最大值大于阈值,那么我开始在那里计算时间。当这个窗口的最大值小于这个值时,我停在那里。这就是我到目前为止所做的:

%Just use the first column in the waveform matrix, 2 gives strange results
w = w(:,1);
%Get threshold value by multiplying max amplitude of waveform and
%predetermined percentage (this varies with testing)
thold = max(w) * .04;

只需要有关如何通过采样窗口实际遍历矩阵的帮助

我不完全确定您想要实现什么,但我认为您可以使用您自己的建议:

soundIdx                      = find(abs(w) > thold)
total_time_w_sound            = sum(abs(w) > thold)/fs;
time_from_first_sound_to_last = (soundIdx(end)-soundIdx(1))/fs;

它是你想找的东西之一吗?

这样我就可以做一些类似的事情:沉默ind=findabsw