annotate AudioDegradationToolbox/degradationUnit_applyHarmonicDistortion.m @ 6:2a219bedc712

added very simple html generating python scripts
author matthiasm
date Wed, 21 Aug 2013 18:18:28 +0100
parents 9d682f5e3927
children
rev   line source
matthiasm@0 1 function [f_audio_out,timepositions_afterDegr] = degradationUnit_applyHarmonicDistortion(f_audio, samplingFreq, timepositions_beforeDegr, parameter)
matthiasm@0 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 3 % Name: degradation_applyHarmonicDistortion
matthiasm@0 4 % Version: 1
matthiasm@0 5 % Date: 2013-01-25
matthiasm@0 6 % Programmer: Matthias Mauch
matthiasm@0 7 %
matthiasm@0 8 % Description:
matthiasm@0 9 % - applies quadratic distortion to the audio
matthiasm@0 10 % - f_audio_out is the distorted audio
matthiasm@0 11 %
matthiasm@0 12 % Input:
matthiasm@0 13 % f_audio - audio signal \in [-1,1]^{NxC} with C being the number of
matthiasm@0 14 % channels
matthiasm@0 15 % timepositions_beforeDegr - some degradations delay the input signal. If
matthiasm@0 16 % some points in time are given via this
matthiasm@0 17 % parameter, timepositions_afterDegr will
matthiasm@0 18 % return the corresponding positions in the
matthiasm@0 19 % output. Set to [] if unavailable. Set f_audio
matthiasm@0 20 % and samplingFreq to [] to compute only
matthiasm@0 21 % timepositions_afterDegr.
matthiasm@0 22 %
matthiasm@0 23 % Input (optional): parameter
matthiasm@0 24 % .nApplications = 3 - number of iterative applications. The higher the
matthiasm@0 25 % stronger
matthiasm@0 26 % .normalizeOutputAudio = 1 - normalize audio
matthiasm@0 27 %
matthiasm@0 28 % Output:
matthiasm@0 29 % f_audio_out - audio signal \in [-1,1]^{NxC} with C being the number
matthiasm@0 30 % of channels
matthiasm@0 31 %
matthiasm@0 32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 33
matthiasm@0 34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 35 % Audio Degradation Toolbox
matthiasm@0 36 %
matthiasm@0 37 % Centre for Digital Music, Queen Mary University of London.
matthiasm@0 38 % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL.
matthiasm@0 39 %
matthiasm@0 40 % This program is free software; you can redistribute it and/or
matthiasm@0 41 % modify it under the terms of the GNU General Public License as
matthiasm@0 42 % published by the Free Software Foundation; either version 2 of the
matthiasm@0 43 % License, or (at your option) any later version. See the file
matthiasm@0 44 % COPYING included with this distribution for more information.
matthiasm@0 45 %
matthiasm@0 46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 47
matthiasm@0 48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 49 % Check parameters
matthiasm@0 50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 51 if nargin<4
matthiasm@0 52 parameter=[];
matthiasm@0 53 end
matthiasm@0 54 if nargin<3
matthiasm@0 55 timepositions_beforeDegr=[];
matthiasm@0 56 end
matthiasm@0 57 if nargin<2
matthiasm@0 58 error('Please specify input data');
matthiasm@0 59 end
matthiasm@0 60
matthiasm@0 61 if isfield(parameter,'nApplications')==0
matthiasm@0 62 parameter.nApplications = 3;
matthiasm@0 63 end
matthiasm@0 64 if isfield(parameter,'normalizeOutputAudio')==0
matthiasm@0 65 parameter.normalizeOutputAudio = 1;
matthiasm@0 66 end
matthiasm@0 67
matthiasm@0 68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 69 % Main program
matthiasm@0 70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matthiasm@0 71
matthiasm@0 72 f_audio_out = [];
matthiasm@0 73 if ~isempty(f_audio)
matthiasm@0 74 f_audio_out = f_audio;
matthiasm@0 75 for ii = 1:parameter.nApplications
matthiasm@0 76 f_audio_out = sin(f_audio_out * pi/2);
matthiasm@0 77 end
matthiasm@0 78
matthiasm@0 79 if parameter.normalizeOutputAudio
matthiasm@0 80 f_audio_out = adthelper_normalizeAudio(f_audio_out, samplingFreq);
matthiasm@0 81 end
matthiasm@0 82
matthiasm@0 83 end
matthiasm@0 84
matthiasm@0 85 % This degradation does not impose a delay
matthiasm@0 86 timepositions_afterDegr = timepositions_beforeDegr;
matthiasm@0 87
matthiasm@0 88 end