annotate AudioDegradationToolbox/applyDegradation.m @ 28:76f45f5c9afd DoP tip

- added units * adaptiveEqualizer * applyMfccMeanAdaption - added corresponding data files for presets - modified applyImpulseReponse to use the estimated average group delay to adjust the output audio and keep the timestamps as is (was vice versa before) - added new units demos, incl one for applyLowpass
author SebastianEwert
date Tue, 21 Jan 2014 18:08:28 +0000
parents 9d682f5e3927
children
rev   line source
matthiasm@0 1 function [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr)
matthiasm@0 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 3 % Name: applyDegradation
matthiasm@0 4 % Date of Revision: 2013-04
matthiasm@0 5 % Programmer: Sebastian Ewert
matthiasm@0 6 %
matthiasm@0 7 % Description:
matthiasm@0 8 % - in the ADT, (high-level) degradations are usually combinations of several
matthiasm@0 9 % degradation units, using specific parameters
matthiasm@0 10 % - the "degradations" directory contains various degradations. They look like this:
matthiasm@0 11 % ----------------------------------------------------------------%
matthiasm@0 12 % degradation_config(1).methodname = 'degradationUnit_applyImpulseResponse';
matthiasm@0 13 % degradation_config(1).parameter.loadInternalIR = 1;
matthiasm@0 14 % degradation_config(1).parameter.internalIR = 'GreatHall1';
matthiasm@0 15 %
matthiasm@0 16 % degradation_config(2).methodname = 'degradationUnit_addNoise';
matthiasm@0 17 % degradation_config(2).parameter.snrRatio = 40; % in dB
matthiasm@0 18 % ----------------------------------------------------------------%
matthiasm@0 19 % - This degradation specifies that f_audio should first be degraded using the
matthiasm@0 20 % degradation unit degradationUnit_applyImpulseResponse and subsequently
matthiasm@0 21 % using degradationUnit_addNoise. This works like a chain
matthiasm@0 22 % - To specify which degradation to use simply set degradationname accordingly.
matthiasm@0 23 % - If you specify timepositions_beforeDegr, then timepositions_afterDegr
matthiasm@0 24 % will contain the corresponding time position in the output audio file.
matthiasm@0 25 % Set f_audio=[] and samplingFreq=0 if you want to process only time
matthiasm@0 26 % positions
matthiasm@0 27 %
matthiasm@0 28 % Input:
matthiasm@0 29 % f_audio - audio signal \in [-1,1]^{NxC} with C being the number of
matthiasm@0 30 % channels
matthiasm@0 31 % samplingFreq - sampling frequency of f_audio
matthiasm@0 32 % timepositions_beforeDegr - some degradations delay the input signal. If
matthiasm@0 33 % some points in time are given via this
matthiasm@0 34 % parameter, timepositions_afterDegr will
matthiasm@0 35 % return the corresponding positions in the
matthiasm@0 36 % output. Set to [] if unavailable. Set f_audio
matthiasm@0 37 % and samplingFreq to [] to compute only
matthiasm@0 38 % timepositions_afterDegr.
matthiasm@0 39 % Output:
matthiasm@0 40 % f_audio_out - audio signal \in [-1,1]^{NxC} with C being the number
matthiasm@0 41 % of channels
matthiasm@0 42 % timepositions_afterDegr - time positions corresponding to timepositions_beforeDegr
matthiasm@0 43 % after all degradations are applied
matthiasm@0 44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 45
matthiasm@0 46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 47 % Audio Degradation Toolbox
matthiasm@0 48 %
matthiasm@0 49 % Centre for Digital Music, Queen Mary University of London.
matthiasm@0 50 % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL.
matthiasm@0 51 %
matthiasm@0 52 % This program is free software; you can redistribute it and/or
matthiasm@0 53 % modify it under the terms of the GNU General Public License as
matthiasm@0 54 % published by the Free Software Foundation; either version 2 of the
matthiasm@0 55 % License, or (at your option) any later version. See the file
matthiasm@0 56 % COPYING included with this distribution for more information.
matthiasm@0 57 %
matthiasm@0 58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 59
matthiasm@0 60 if nargin<4
matthiasm@0 61 timepositions_beforeDegr=[];
matthiasm@0 62 end
matthiasm@0 63 if nargin<3
matthiasm@0 64 error('Please specify the required input variables')
matthiasm@0 65 end
matthiasm@0 66
matthiasm@0 67 % the degradations are in a subdirectory called "degradations" of the folder this
matthiasm@0 68 % function is in
matthiasm@0 69 fullFilenameMfile = mfilename('fullpath');
matthiasm@0 70 [pathstr,name,ext] = fileparts(fullFilenameMfile);
matthiasm@0 71 dirDegradations = fullfile(pathstr,'degradations');
matthiasm@0 72
matthiasm@0 73 % add dirDegradations to matlab path if it is not included yet. Otherwise we
matthiasm@0 74 % cannot call the degradation functions
matthiasm@0 75 addpath(dirDegradations);
matthiasm@0 76
matthiasm@0 77 % retrieve the degradation configuration
matthiasm@0 78 degradationFunction = str2func(degradationname);
matthiasm@0 79 degradation_config = degradationFunction();
matthiasm@0 80
matthiasm@0 81 % traverse degradation_config and call all the degradation units specified in there
matthiasm@0 82 numDegradationUnits = length(degradation_config);
matthiasm@0 83 f_audio_out = f_audio;
matthiasm@0 84 timepositions_afterDegr = timepositions_beforeDegr;
matthiasm@0 85 for n=1:numDegradationUnits
matthiasm@0 86 degradationFunction = str2func(degradation_config(n).methodname);
matthiasm@0 87 [f_audio_out,timepositions_afterDegr] = degradationFunction(f_audio_out, samplingFreq, timepositions_afterDegr, degradation_config(n).parameter);
matthiasm@0 88 end
matthiasm@0 89
matthiasm@0 90 end
matthiasm@0 91
matthiasm@0 92
matthiasm@0 93
matthiasm@0 94
matthiasm@0 95
matthiasm@0 96
matthiasm@0 97