Chris@0: function [f_feature_stat,newFeatureRate] = smoothDownsampleFeature(f_feature,parameter) Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Name: smoothDownsampleFeature Chris@0: % Date of Revision: 2011-03 Chris@0: % Programmer: Meinard Mueller, Sebastian Ewert Chris@0: % Chris@0: % Description: Chris@0: % - Temporal smoothing and downsampling of a feature sequence Chris@0: % Chris@0: % Remark: Chris@0: % - parameter.featureRate specifies the input feature rate. This value is Chris@0: % used to derive the output feature rate. Chris@0: % Chris@0: % Input: Chris@0: % f_feature Chris@0: % parameter.winLenSmooth = 1; Chris@0: % parameter.downsampSmooth = 1; Chris@0: % parameter.inputFeatureRate = 0; Chris@0: % Chris@0: % Output: Chris@0: % f_feature Chris@0: % newFeatureRate Chris@0: % Chris@0: % License: Chris@0: % This file is part of 'Chroma Toolbox'. Chris@0: % Chris@0: % 'Chroma Toolbox' is free software: you can redistribute it and/or modify Chris@0: % it under the terms of the GNU General Public License as published by Chris@0: % the Free Software Foundation, either version 2 of the License, or Chris@0: % (at your option) any later version. Chris@0: % Chris@0: % 'Chroma Toolbox' is distributed in the hope that it will be useful, Chris@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: % GNU General Public License for more details. Chris@0: % Chris@0: % You should have received a copy of the GNU General Public License Chris@0: % along with 'Chroma Toolbox'. If not, see . Chris@0: % Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Check parameters Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: if nargin<2 Chris@0: parameter=[]; Chris@0: end Chris@0: if nargin<1 Chris@0: error('Please specify input data'); Chris@0: end Chris@0: if isfield(parameter,'winLenSmooth')==0 Chris@0: parameter.winLenSmooth = 1; Chris@0: end Chris@0: if isfield(parameter,'downsampSmooth')==0 Chris@0: parameter.downsampSmooth = 1; Chris@0: end Chris@0: if isfield(parameter,'inputFeatureRate')==0 Chris@0: parameter.inputFeatureRate = 0; Chris@0: end Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Main program Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: % Temporal Smoothing Chris@0: if (parameter.winLenSmooth ~= 1) || (parameter.downsampSmooth ~= 1) Chris@0: winLenSmooth = parameter.winLenSmooth; Chris@0: downsampSmooth = parameter.downsampSmooth; Chris@0: stat_window = hanning(winLenSmooth); Chris@0: stat_window = stat_window/sum(stat_window); Chris@0: Chris@0: % upfirdn filters and downsamples each column of f_stat_help Chris@0: f_feature_stat = zeros(size(f_feature)); Chris@0: f_feature_stat = (upfirdn(f_feature',stat_window,1,downsampSmooth))'; Chris@0: seg_num = size(f_feature,2); Chris@0: stat_num = ceil(seg_num/downsampSmooth); Chris@0: cut = floor((winLenSmooth-1)/(2*downsampSmooth)); Chris@0: f_feature_stat = f_feature_stat(:,(1+cut:stat_num+cut)); %adjust group delay Chris@0: else Chris@0: f_feature_stat = f_feature; Chris@0: end Chris@0: Chris@0: newFeatureRate = parameter.inputFeatureRate / parameter.downsampSmooth; Chris@0: Chris@0: end Chris@0: