我想找到所有值高于音频文件平均样本值的样本。这是代码。
function AudioLevels(a, fps)
clc
format long g
[y f nbits] = wavread(a);
len = length(y);
t = 0:1/f:(length(y)-1)/f;
plot(t, abs(y(:,1))), grid on;
meanAudioLevel = sum(abs(y(:,1)))/length(y);
samplesPerFrame = f/fps;
noOfFrames = ceil(double(length(y)/samplesPerFrame));
array1= [;];
%---------------------------------------------------------------------
for i = 1 : 1 : noOfFrames-1;
for j = 1+(samplesPerFrame*(i-1)) : 1 : (samplesPerFrame*i)
array = [;];
array = [array ; abs(y(j,1))];
end
if (sum(array) >= meanAudioLevel)
array1 = [array1 ; sum(array)];
fprintf (fileIO, '%d\t%f\r\n', i ,sum(array));
end
end
%---------------------------------------------------------------------
for j = length(y) - mod (length(y), samplesPerFrame)+1 : 1 : length(y)
array = [;];
array = [array ; abs(y(j,1))];
end
if (sum(array) >= meanAudioLevel)
array1 = [array1 ; sum(array)];
end
%---------------------------------------------------------------------
array1