SebastianEwert@28: function [f_audio_out,timepositions_afterDegr] = adthelper_normalizeAudio(f_audio, samplingFreq, timepositions_beforeDegr, parameter) SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: % Name: adthelper_normalizeAudio SebastianEwert@28: % Date of Revision: 2013-04 SebastianEwert@28: % Programmer: Sebastian Ewert SebastianEwert@28: % SebastianEwert@28: % Description: SebastianEwert@28: % - normalizes audio SebastianEwert@28: % SebastianEwert@28: % Input: SebastianEwert@28: % f_audio - audio signal \in [-1,1]^{NxC} with C being the number of SebastianEwert@28: % channels SebastianEwert@28: % samplingFreq - sampling frequency of f_audio SebastianEwert@28: % timepositions_beforeDegr - some degradations delay the input signal. If SebastianEwert@28: % some points in time are given via this SebastianEwert@28: % parameter, timepositions_afterDegr will SebastianEwert@28: % return the corresponding positions in the SebastianEwert@28: % output. Set to [] if unavailable. Set f_audio SebastianEwert@28: % and samplingFreq to [] to compute only SebastianEwert@28: % timepositions_afterDegr. SebastianEwert@28: % SebastianEwert@28: % Input (optional): parameter SebastianEwert@28: % .maxAmplitude = 0.999; SebastianEwert@28: % SebastianEwert@28: % Output: SebastianEwert@28: % f_audio_out - audio signal \in [-1,1]^{NxC} with C being the number of SebastianEwert@28: % channels SebastianEwert@28: % timepositions_afterDegr - time positions corresponding to timepositions_beforeDegr SebastianEwert@28: % SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: % Audio Degradation Toolbox SebastianEwert@28: % SebastianEwert@28: % Centre for Digital Music, Queen Mary University of London. SebastianEwert@28: % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL. SebastianEwert@28: % SebastianEwert@28: % This program is free software; you can redistribute it and/or SebastianEwert@28: % modify it under the terms of the GNU General Public License as SebastianEwert@28: % published by the Free Software Foundation; either version 2 of the SebastianEwert@28: % License, or (at your option) any later version. See the file SebastianEwert@28: % COPYING included with this distribution for more information. SebastianEwert@28: % SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: % Check parameters SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: if nargin<4 SebastianEwert@28: parameter=[]; SebastianEwert@28: end SebastianEwert@28: if nargin<3 SebastianEwert@28: timepositions_beforeDegr=[]; SebastianEwert@28: end SebastianEwert@28: if nargin<2 SebastianEwert@28: error('Please specify input data'); SebastianEwert@28: end SebastianEwert@28: if isfield(parameter,'maxAmplitude')==0 SebastianEwert@28: parameter.maxAmplitude = 0.999; SebastianEwert@28: end SebastianEwert@28: SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: % Main program SebastianEwert@28: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SebastianEwert@28: SebastianEwert@28: f_audio_out = []; SebastianEwert@28: if ~isempty(f_audio) SebastianEwert@28: f_audio_out = parameter.maxAmplitude * f_audio / max(max(max(abs(f_audio))),eps); SebastianEwert@28: end SebastianEwert@28: SebastianEwert@28: % This function does not impose a delay SebastianEwert@28: timepositions_afterDegr = timepositions_beforeDegr; SebastianEwert@28: SebastianEwert@28: end SebastianEwert@28: SebastianEwert@28: SebastianEwert@28: