?? estnoisem.m
字號:
function [x,zo,xs]=estnoisem(yf,tz,pp)
%ESTNOISEM - estimate noise spectrum using minimum statistics
% Inputs:
% yf input power spectra (one row per frame)
% tz frame increment in seconds
% Alternatively, the input state from a previous call (see below)
% pp algorithm parameters [optional]
%
% Outputs:
% x estimated noise power spectra (one row per frame)
% zo output state
% xs estimated std error of x (one row per frame)
% xs seems often to be an underestimate by a factor of 2 or 3
%
% The algorithm parameters are defined in reference [1] from which equation
% numbers are given in parentheses. They are as follows:
%
% pp.taca % (11): smoothing time constant for alpha_c [0.0449 seconds]
% pp.tamax % (3): max smoothing time constant [0.392 seconds]
% pp.taminh % (3): min smoothing time constant (upper limit) [0.0133 seconds]
% pp.tpfall % (12): time constant for P to fall [0.064 seconds]
% pp.tbmax % (20): max smoothing time constant [0.0717 seconds]
% pp.qeqmin % (23): minimum value of Qeq [2]
% pp.qeqmax % max value of Qeq per frame [14]
% pp.av % (23)+13 lines: fudge factor for bc calculation [2.12]
% pp.td % time to take minimum over [1.536 seconds]
% pp.nu % number of subwindows to use [3]
% pp.qith % Q-inverse thresholds to select maximum noise slope [0.03 0.05 0.06 Inf ]
% pp.nsmdb % corresponding noise slope thresholds in dB/second [47 31.4 15.7 4.1]
%
% Example use: y=enframe(s,w,ni); % divide speech signal s(n) into
% % overlapping frames using window w(n)
% yf=rfft(y,nf,2); % take fourier transform
% dp=estnoisem(yf.*conj(yf),tinc); % estimate the noise
%
% If convenient, you can call estnoisem in chunks of arbitrary size. Thus the following are equivalent:
%
% (a) dp=estnoisem(yp(1:300),tinc);
%
% (b) [dp(1:100),z]=estnoisem(yp(1:100),tinc);
% [dp(101:200),z]=estnoisem(yp(101:200),z);
% [dp(201:300),z]=estnoisem(yp(201:300),z);
% This is intended to be a precise implementation of [1] with Table III
% replaced by the updated table 5 from [2]. The only deliberate algorithm
% change is the introduction of a minimum value for 1/Qeq in equation (23).
% This change only affects the first few frames and improves the
% convergence of the algorithm. A minor improveemnt was reported in [3] but
% this has not yet been included.
%
% Refs:
% [1] Rainer Martin.
% Noise power spectral density estimation based on optimal smoothing and minimum statistics.
% IEEE Trans. Speech and Audio Processing, 9(5):504-512, July 2001.
% [2] Rainer Martin.
% Bias compensation methods for minimum statistics noise power spectral density estimation
% Signal Processing, 2006, 86, 1215-1229
% [3] Dirk Mauler and Rainer Martin
% Noise power spectral density estimation on highly correlated data
% Proc IWAENC, 2006
% Copyright (C) Mike Brookes 2008
% Version: $Id: estnoisem.m,v 1.1 2008/05/22 17:17:02 dmb Exp $
%
% VOICEBOX is a MATLAB toolbox for speech processing.
% Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You can obtain a copy of the GNU General Public License from
% http://www.gnu.org/copyleft/gpl.html or by writing to
% Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[nr,nrf]=size(yf); % number of frames and freq bins
x=zeros(nr,nrf); % initialize output arrays
xs=zeros(nr,nrf); % will hold std error in the future
if isempty(yf) && isstruct(tz) % no real data
zo=tz; % just keep the same state
else
if isstruct(tz) % take parameters from a previous call
nrcum=tz.nrcum;
p=tz.p; % smoothed power spectrum
ac=tz.ac; % correction factor (9)
sn2=tz.sn2; % estimated noise power
pb=tz.pb; % smoothed noisy speech power (20)
pb2=tz.pb2;
pminu=tz.pminu;
actmin=tz.actmin; % Running minimum estimate
actminsub=tz.actminsub; % sub-window minimum estimate
subwc=tz.subwc; % force a buffer switch on first loop
actbuf=tz.actbuf; % buffer to store subwindow minima
ibuf=tz.ibuf;
lminflag=tz.lminflag; % flag to remember local minimum
tinc=tz.tinc; % frame increment
qq=tz.qq; % parameter structure
else
tinc = tz; % second argument is frame increment
nrcum=0; % no frames so far
% default algorithm constants
qq.taca=0.0449; % smoothing time constant for alpha_c = -tinc/log(0.7) in equ (11)
qq.tamax=0.392; % max smoothing time constant in (3) = -tinc/log(0.96)
qq.taminh=0.0133; % min smoothing time constant (upper limit) in (3) = -tinc/log(0.3)
qq.tpfall=0.064; % time constant for P to fall (12)
qq.tbmax=0.0717; % max smoothing time constant in (20) = -tinc/log(0.8)
qq.qeqmin=2; % minimum value of Qeq (23)
qq.qeqmax=14; % max value of Qeq per frame
qq.av=2.12; % fudge factor for bc calculation (23 + 13 lines)
qq.td=1.536; % time to take minimum over
qq.nu=8; % number of subwindows
qq.qith=[0.03 0.05 0.06 Inf]; % noise slope thresholds in dB/s
qq.nsmdb=[47 31.4 15.7 4.1];
if nargin>=3 && ~isempty(pp)
qqn=fieldnames(qq);
for i=1:length(qqn)
if isfield(pp,qqn{i})
qq.(qqn{i})=pp.(qqn{i});
end
end
end
end
% unpack parameter structure
taca=qq.taca; % smoothing time constant for alpha_c = -tinc/log(0.7) in equ (11)
tamax=qq.tamax; % max smoothing time constant in (3) = -tinc/log(0.96)
taminh=qq.taminh; % min smoothing time constant (upper limit) in (3) = -tinc/log(0.3)
tpfall=qq.tpfall; % time constant for P to fall (12)
tbmax=qq.tbmax; % max smoothing time constant in (20) = -tinc/log(0.8)
qeqmin=qq.qeqmin; % minimum value of Qeq (23)
qeqmax=qq.qeqmax; % max value of Qeq per frame
av=qq.av; % fudge factor for bc calculation (23 + 13 lines)
td=qq.td; % time to take minimum over
nu=qq.nu; % number of subwindows
qith=qq.qith; % noise slope thresholds in dB/s
nsmdb=qq.nsmdb; % maximum permitted +ve noise slope in dB/s
% derived algorithm constants
aca=exp(-tinc/taca); % smoothing constant for alpha_c in equ (11) = 0.7
acmax=aca; % min value of alpha_c = 0.7 in equ (11) also = 0.7
amax=exp(-tinc/tamax); % max smoothing constant in (3) = 0.96
aminh=exp(-tinc/taminh); % min smoothing constant (upper limit) in (3) = 0.3
bmax=exp(-tinc/tbmax); % max smoothing constant in (20) = 0.8
snrexp = -tinc/tpfall;
nv=round(td/(tinc*nu)); % length of each subwindow in frames
if nv<4 % algorithm doesn't work for miniscule frames
nv=4;
nu=max(round(td/(tinc*nv)),1);
end
nd=nu*nv; % length of total window in frames
[md,hd]=mhvals(nd); % calculate the constants M(D) and H(D) from Table III
[mv,hv]=mhvals(nv); % calculate the constants M(D) and H(D) from Table III
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -