Mercurial > hg > audio-degradation-toolbox
view AudioDegradationToolbox/degradationUnit_applyHarmonicDistortion.m @ 11:2d0ed50c547f version 0.11
Removed tag version 0.11
author | matthiasm |
---|---|
date | Wed, 21 Aug 2013 19:18:43 +0100 |
parents | 9d682f5e3927 |
children |
line wrap: on
line source
function [f_audio_out,timepositions_afterDegr] = degradationUnit_applyHarmonicDistortion(f_audio, samplingFreq, timepositions_beforeDegr, parameter) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Name: degradation_applyHarmonicDistortion % Version: 1 % Date: 2013-01-25 % Programmer: Matthias Mauch % % Description: % - applies quadratic distortion to the audio % - f_audio_out is the distorted audio % % Input: % f_audio - audio signal \in [-1,1]^{NxC} with C being the number of % channels % timepositions_beforeDegr - some degradations delay the input signal. If % some points in time are given via this % parameter, timepositions_afterDegr will % return the corresponding positions in the % output. Set to [] if unavailable. Set f_audio % and samplingFreq to [] to compute only % timepositions_afterDegr. % % Input (optional): parameter % .nApplications = 3 - number of iterative applications. The higher the % stronger % .normalizeOutputAudio = 1 - normalize audio % % Output: % f_audio_out - audio signal \in [-1,1]^{NxC} with C being the number % of channels % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Audio Degradation Toolbox % % Centre for Digital Music, Queen Mary University of London. % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL. % % 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. See the file % COPYING included with this distribution for more information. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Check parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if nargin<4 parameter=[]; end if nargin<3 timepositions_beforeDegr=[]; end if nargin<2 error('Please specify input data'); end if isfield(parameter,'nApplications')==0 parameter.nApplications = 3; end if isfield(parameter,'normalizeOutputAudio')==0 parameter.normalizeOutputAudio = 1; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Main program %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f_audio_out = []; if ~isempty(f_audio) f_audio_out = f_audio; for ii = 1:parameter.nApplications f_audio_out = sin(f_audio_out * pi/2); end if parameter.normalizeOutputAudio f_audio_out = adthelper_normalizeAudio(f_audio_out, samplingFreq); end end % This degradation does not impose a delay timepositions_afterDegr = timepositions_beforeDegr; end