SebastianEwert@28
|
1 function [f_audio_out,timepositions_afterDegr] = adthelper_normalizeAudio(f_audio, samplingFreq, timepositions_beforeDegr, parameter)
|
SebastianEwert@28
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
3 % Name: adthelper_normalizeAudio
|
SebastianEwert@28
|
4 % Date of Revision: 2013-04
|
SebastianEwert@28
|
5 % Programmer: Sebastian Ewert
|
SebastianEwert@28
|
6 %
|
SebastianEwert@28
|
7 % Description:
|
SebastianEwert@28
|
8 % - normalizes audio
|
SebastianEwert@28
|
9 %
|
SebastianEwert@28
|
10 % Input:
|
SebastianEwert@28
|
11 % f_audio - audio signal \in [-1,1]^{NxC} with C being the number of
|
SebastianEwert@28
|
12 % channels
|
SebastianEwert@28
|
13 % samplingFreq - sampling frequency of f_audio
|
SebastianEwert@28
|
14 % timepositions_beforeDegr - some degradations delay the input signal. If
|
SebastianEwert@28
|
15 % some points in time are given via this
|
SebastianEwert@28
|
16 % parameter, timepositions_afterDegr will
|
SebastianEwert@28
|
17 % return the corresponding positions in the
|
SebastianEwert@28
|
18 % output. Set to [] if unavailable. Set f_audio
|
SebastianEwert@28
|
19 % and samplingFreq to [] to compute only
|
SebastianEwert@28
|
20 % timepositions_afterDegr.
|
SebastianEwert@28
|
21 %
|
SebastianEwert@28
|
22 % Input (optional): parameter
|
SebastianEwert@28
|
23 % .maxAmplitude = 0.999;
|
SebastianEwert@28
|
24 %
|
SebastianEwert@28
|
25 % Output:
|
SebastianEwert@28
|
26 % f_audio_out - audio signal \in [-1,1]^{NxC} with C being the number of
|
SebastianEwert@28
|
27 % channels
|
SebastianEwert@28
|
28 % timepositions_afterDegr - time positions corresponding to timepositions_beforeDegr
|
SebastianEwert@28
|
29 %
|
SebastianEwert@28
|
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
31
|
SebastianEwert@28
|
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
33 % Audio Degradation Toolbox
|
SebastianEwert@28
|
34 %
|
SebastianEwert@28
|
35 % Centre for Digital Music, Queen Mary University of London.
|
SebastianEwert@28
|
36 % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL.
|
SebastianEwert@28
|
37 %
|
SebastianEwert@28
|
38 % This program is free software; you can redistribute it and/or
|
SebastianEwert@28
|
39 % modify it under the terms of the GNU General Public License as
|
SebastianEwert@28
|
40 % published by the Free Software Foundation; either version 2 of the
|
SebastianEwert@28
|
41 % License, or (at your option) any later version. See the file
|
SebastianEwert@28
|
42 % COPYING included with this distribution for more information.
|
SebastianEwert@28
|
43 %
|
SebastianEwert@28
|
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
45
|
SebastianEwert@28
|
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
47 % Check parameters
|
SebastianEwert@28
|
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
49 if nargin<4
|
SebastianEwert@28
|
50 parameter=[];
|
SebastianEwert@28
|
51 end
|
SebastianEwert@28
|
52 if nargin<3
|
SebastianEwert@28
|
53 timepositions_beforeDegr=[];
|
SebastianEwert@28
|
54 end
|
SebastianEwert@28
|
55 if nargin<2
|
SebastianEwert@28
|
56 error('Please specify input data');
|
SebastianEwert@28
|
57 end
|
SebastianEwert@28
|
58 if isfield(parameter,'maxAmplitude')==0
|
SebastianEwert@28
|
59 parameter.maxAmplitude = 0.999;
|
SebastianEwert@28
|
60 end
|
SebastianEwert@28
|
61
|
SebastianEwert@28
|
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
63 % Main program
|
SebastianEwert@28
|
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
SebastianEwert@28
|
65
|
SebastianEwert@28
|
66 f_audio_out = [];
|
SebastianEwert@28
|
67 if ~isempty(f_audio)
|
SebastianEwert@28
|
68 f_audio_out = parameter.maxAmplitude * f_audio / max(max(max(abs(f_audio))),eps);
|
SebastianEwert@28
|
69 end
|
SebastianEwert@28
|
70
|
SebastianEwert@28
|
71 % This function does not impose a delay
|
SebastianEwert@28
|
72 timepositions_afterDegr = timepositions_beforeDegr;
|
SebastianEwert@28
|
73
|
SebastianEwert@28
|
74 end
|
SebastianEwert@28
|
75
|
SebastianEwert@28
|
76
|
SebastianEwert@28
|
77
|