资源简介
音频分割小程序,用matlab实现,里面有三个.m文件。
代码片段和文件信息
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [yfsposition] = audioSeg(filenmclipLen)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%This is main audio stream segment functionit can classfication the audio file to different segments.
%
%input:
% filenm = the flie which need to be classification;
% clipLen = segment clip lengthunit is framedefault value is 100;
%output:
% y = the points vector of the file;
% fs = sample rate;
% position = type change points;
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Written by Qian Yong Gao %%
%% Data:June 232006 %%
%% Update:June 232006 by Qian Yong Gao %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin < 2
clipLen = 100;
end
[fidmsg] = fopen(filenm‘rb‘);%open file
error(msg);
fseek(fid8-1);%file point rewind
header = fread(fid4‘uchar‘);
% makesure ‘*wav‘ file format
if header‘ ~= ‘WAVE‘
error(‘This file is not a wavfile‘);
else
fseek(fid80);
iPCM = fread(fid1‘ushort‘);%PCM code format
iMono = fread(fid1‘ushort‘);%Mono channel
if (iPCM ~= 1) & (iMono ~= 1)
error(‘This wavefile is not Mono PCM type‘);
end
end
fs = fread(fid1‘ushort‘);%sample rate
fseek(fid80);
nBit = fread(fid1‘ushort‘);%each sample bits
nByte = nBit/8;%each sample bytes;
header = fread(fid4‘uchar‘);
if header‘ ~= ‘data‘
error(‘The file is corrupt‘);
end
if nByte == 1
nData = fread(fid1‘ulong‘); %file samples number
rid = ‘uchar‘;
else
nData = fread(fid1‘ulong‘) / 2;
rid = ‘short‘;
end
position = 0;%beginning position is ‘0‘
nRead = 0; %n samples read
nframe = 0; %n frame read
segLen = 0; %n clip read
y = [];%signal read
frameLen = floor(0.02 * fs); %frame length
frameMov = ceil(0.01 * fs); %frame step
overlap = frameLen - frameMov;%frame overlap
while nRead <= nData - frameLen
y1 = fread(fidframeLenrid);%read a frame
nRead = nRead + frameMov;%read samples number increase frameMov
if fid == ‘uchar‘
y1 = (y1 - 128) / 128 ;
fseek(fid-overlap0);%8 bitrewind file pointer overlap bites
else
y1 = y1 / 32768;
fseek(fid-2 * overlap0);%16 bitrewind file pointer 2*overlap bites
end
nframe = nframe + 1;%increase read frame number
y = [y;y1‘];%read signal
%when read frame is clipLen‘s integer timesnClip increase 1
segLen = segLen + 1;
if segLen == 3*clipLen
clipMat = y([nframe-3*clipLen+1:nframe]:);%clip matrix which wait for classifcation
f = fft(clipMat‘.*(hamming(frameLen)*ones(13*clipLen))1024);
f = abs(f);
mfc = melfc(f3030);
segN = BeyasInfoCrit(mfcframeLenframeMov0.6);
if (segN>=clipLen) & (segN<=2*clipLen)
position = [position;nframe-3*clipLen+segN];
segLen = 3 * clipLen - segN;
else
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3420 2009-12-08 16:47 音频分割\audioSeg.m
文件 1516 2009-12-08 16:27 音频分割\BeyasInfoCrit.m
文件 6706 2009-12-08 16:43 音频分割\mfcc.m
目录 0 2009-12-22 16:31 音频分割
----------- --------- ---------- ----- ----
11642 4
- 上一篇:Bezier曲线拟合Matlab
- 下一篇:MATLAB四阶龙格库塔算法
评论
共有 条评论