📄 test_subfingerprint.m
字号:
% zorro write test_subfingerprint
% Author: zorro
% Date: 2007-3-4
function [s1_subfingerprint,aspc] = test_subfingerprint(wavefile,method,startpos,length)
if nargin < 2; method = 0; end
if nargin < 3; startpos = 1; end
if nargin < 4; length = 90*1024; end
% Load a speech waveform
[d,sr] = wavread(wavefile, [startpos, startpos + length]); %'buddy.wav');
if 1 == method
d = decimate(d,2); sr = sr/2; %decimate2
end
if 2 == method
d = decimate(d,4); sr = sr/4; %decimate4
end
if 3 == method
d = decimate(d,8); sr = sr/8; %decimate8
end
if 4 == method
d = downsample(d,2); sr = sr/2; %downsample2
end
if 5 == method
d = downsample(d,4); sr = sr/4; %downsample4
end
if 6 == method
N = randn(1,length(d));%guassis noise;
d=d+N';
end
if 7 == method
N=rand(1,length(d));%white noise;
d=d+N';
end
subplot(521)
plot(d);
ylabel('Amplitude')
title('original wave')
% Look at its regular spectrogram
subplot(523)
specgram(d, 256, sr);
title('original spectrogram')
% Calculate basic RASTA-PLP cepstra and spectra
[cep1, spec1] = rastaplp(d, sr);
% Convert to MFCCs very close to those genrated by feacalc -sr 22050 -nyq
% 8000 -dith -hpf -opf htk -delta 0 -plp no -dom cep -com yes -frq mel -filt tri -win 32 -step 16 -cep 20
% [mm,aspc,pspc] = melfcc(d*3.3752, sr, 'minfreq', 300, 'maxfreq', 2000, 'numcep', 33, 'nbands', 33, 'fbtype', 'fcmel', 'dcttype', 1, 'usecmp', 1, 'wintime', 0.037, 'hoptime', 0.0116, 'preemph', 0, 'dither', 1);
[mm,aspc,pspc] = melfcc(d*3.3752, sr, 'minfreq', 300, 'maxfreq', 2000, 'sumpower',0, 'numcep', 33, 'nbands', 33, 'fbtype', 'bark', 'dcttype', 1, 'usecmp', 1, 'wintime', 0.037, 'hoptime', 0.0116, 'preemph', 0, 'dither', 1);
% .. and plot them
subplot(525)
imagesc(10*log10(pspc)); % Power spectrum, so dB is 10log10
title('Power spectrum features')
ylabel('dB')
axis xy
subplot(527)
imagesc(aspc)
title('33-band bark filter-bank')
xlabel('time/10ms frames')
axis xy
% Notice the auditory warping of the frequency axis to give more
% space to low frequencies and the way that RASTA filtering
% emphasizes the onsets of static sounds like vowels
aspc=filter([1,-1],1,aspc);
[dim,len] = size(aspc);
s1_fingerprint = zeros(dim,32);
s1_subfingerprint = zeros(256,32);
for n=1:len
for m=1:32
if n==1
t=aspc(m,n)-aspc(m+1,n);
else
t=aspc(m,n)-aspc(m+1,n)-aspc(m,n-1)-aspc(m+1,n-1);
end
if t>0
if n<256
s1_subfingerprint(n,m)=1;
end
s1_fingerprint(n,m)=1;
end
end
end
% .. and plot them
subplot(529)
imagesc(s1_subfingerprint);
title('the first fingerprint band')
axis xy
subplot(5,2,[2 4 6 8 10])
imagesc(s1_fingerprint);
title('fingerprint')
axis xy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -