matthiasm@0
|
1
|
matthiasm@0
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
matthiasm@0
|
3 % Audio Degradation Toolbox
|
matthiasm@0
|
4 %
|
matthiasm@0
|
5 % Centre for Digital Music, Queen Mary University of London.
|
matthiasm@0
|
6 % This file copyright 2013 Sebastian Ewert, Matthias Mauch and QMUL.
|
SebastianEwert@4
|
7 %
|
matthiasm@0
|
8 % This program is free software; you can redistribute it and/or
|
matthiasm@0
|
9 % modify it under the terms of the GNU General Public License as
|
matthiasm@0
|
10 % published by the Free Software Foundation; either version 2 of the
|
matthiasm@0
|
11 % License, or (at your option) any later version. See the file
|
matthiasm@0
|
12 % COPYING included with this distribution for more information.
|
matthiasm@0
|
13 %
|
matthiasm@0
|
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
matthiasm@0
|
15
|
matthiasm@0
|
16 % Note: Some degradations impose a delay/temporal distortion on the input
|
matthiasm@0
|
17 % data. The last example shows, given time positions before the
|
matthiasm@0
|
18 % degradation, how the corresponding time positions after the degradation
|
matthiasm@0
|
19 % can be retrieved
|
matthiasm@0
|
20
|
matthiasm@0
|
21 %%
|
matthiasm@0
|
22
|
matthiasm@0
|
23 clear
|
matthiasm@0
|
24
|
matthiasm@23
|
25 addpath(genpath(fullfile(pwd,'AudioDegradationToolbox')));
|
matthiasm@0
|
26
|
matthiasm@0
|
27 pathOutputDemo = 'demoOutput/';
|
matthiasm@0
|
28 if ~exist(pathOutputDemo,'dir'), mkdir(pathOutputDemo); end
|
matthiasm@0
|
29
|
SebastianEwert@4
|
30 filenames = {
|
SebastianEwert@4
|
31 'testdata/RWC_G39.wav';
|
SebastianEwert@4
|
32 'testdata/RWC_G72.wav';
|
SebastianEwert@4
|
33 'testdata/RWC_G84.wav';
|
SebastianEwert@4
|
34 'testdata/RWC_P009m_drum.wav';
|
SebastianEwert@4
|
35 'testdata/RWC-C08.wav';
|
matthiasm@7
|
36 'testdata/session5-faure_elegie2c-001-0.wav';
|
matthiasm@7
|
37 'testdata/175234__kenders2000__nonsense-sentence.wav';
|
SebastianEwert@4
|
38 };
|
matthiasm@0
|
39
|
matthiasm@9
|
40 createSpectrograms = 0;
|
matthiasm@0
|
41
|
matthiasm@0
|
42 %%
|
SebastianEwert@4
|
43 % just copying original files to the demo folder
|
SebastianEwert@5
|
44 maxValueRangeVis = zeros(length(filenames));
|
SebastianEwert@4
|
45 for k=1:length(filenames)
|
SebastianEwert@4
|
46 copyfile(filenames{k}, fullfile(pathOutputDemo,sprintf('00_Original_file%d.wav',k)))
|
SebastianEwert@4
|
47 if createSpectrograms
|
SebastianEwert@4
|
48 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
49 [s,f,t] = spectrogram(f_audio,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
50 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('00_Original_file%d.png',k)))
|
SebastianEwert@5
|
51 maxValueRangeVis(k) = max(max(log10(abs(s)+1)));
|
SebastianEwert@4
|
52 end
|
SebastianEwert@4
|
53 end
|
matthiasm@0
|
54
|
matthiasm@0
|
55 %%
|
SebastianEwert@4
|
56 for k=1:length(filenames)
|
SebastianEwert@4
|
57 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
58
|
SebastianEwert@4
|
59 f_audio_out = applyDegradation('liveRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
60
|
SebastianEwert@4
|
61 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_01_liveRecording_file%d.wav',k)));
|
SebastianEwert@4
|
62 if createSpectrograms
|
SebastianEwert@4
|
63 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
64 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_01_liveRecording_file%d.png',k)))
|
SebastianEwert@4
|
65 end
|
SebastianEwert@4
|
66 end
|
matthiasm@0
|
67
|
matthiasm@0
|
68 %%
|
SebastianEwert@4
|
69 for k=1:length(filenames)
|
SebastianEwert@4
|
70 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
71
|
SebastianEwert@4
|
72 f_audio_out = applyDegradation('strongMp3Compression', f_audio, samplingFreq);
|
SebastianEwert@4
|
73
|
SebastianEwert@4
|
74 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_02_strongMp3Compression_file%d.wav',k)));
|
SebastianEwert@4
|
75 if createSpectrograms
|
SebastianEwert@4
|
76 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
77 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_02_strongMp3Compression_file%d.png',k)))
|
SebastianEwert@4
|
78 end
|
SebastianEwert@4
|
79 end
|
matthiasm@0
|
80
|
matthiasm@0
|
81 %%
|
SebastianEwert@4
|
82 for k=1:length(filenames)
|
SebastianEwert@4
|
83 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
84
|
SebastianEwert@4
|
85 f_audio_out = applyDegradation('vinylRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
86
|
SebastianEwert@4
|
87 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_03_vinylRecording_file%d.wav',k)));
|
SebastianEwert@4
|
88 if createSpectrograms
|
SebastianEwert@4
|
89 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
90 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_03_vinylRecording_file%d.png',k)))
|
SebastianEwert@4
|
91 end
|
SebastianEwert@4
|
92 end
|
matthiasm@0
|
93
|
matthiasm@0
|
94 %%
|
SebastianEwert@4
|
95 for k=1:length(filenames)
|
SebastianEwert@4
|
96 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
97
|
SebastianEwert@4
|
98 f_audio_out = applyDegradation('radioBroadcast', f_audio, samplingFreq);
|
SebastianEwert@4
|
99
|
SebastianEwert@4
|
100 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_04_radioBroadcast_file%d.wav',k)));
|
SebastianEwert@4
|
101 if createSpectrograms
|
SebastianEwert@4
|
102 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
103 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_04_radioBroadcast_file%d.png',k)))
|
SebastianEwert@4
|
104 end
|
SebastianEwert@4
|
105 end
|
matthiasm@0
|
106
|
SebastianEwert@4
|
107 %%
|
SebastianEwert@4
|
108 for k=1:length(filenames)
|
SebastianEwert@4
|
109 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
110
|
SebastianEwert@4
|
111 f_audio_out = applyDegradation('smartPhoneRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
112
|
SebastianEwert@4
|
113 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_05_smartPhoneRecording_file%d.wav',k)));
|
SebastianEwert@4
|
114 if createSpectrograms
|
SebastianEwert@4
|
115 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
116 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_05_smartPhoneRecording_file%d.png',k)))
|
SebastianEwert@4
|
117 end
|
SebastianEwert@4
|
118 end
|
matthiasm@0
|
119
|
SebastianEwert@4
|
120 %%
|
SebastianEwert@4
|
121 for k=1:length(filenames)
|
SebastianEwert@4
|
122 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
123
|
SebastianEwert@4
|
124 f_audio_out = applyDegradation('smartPhonePlayback', f_audio, samplingFreq);
|
SebastianEwert@4
|
125
|
SebastianEwert@4
|
126 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_06_smartPhonePlayback_file%d.wav',k)));
|
SebastianEwert@4
|
127 if createSpectrograms
|
SebastianEwert@4
|
128 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@5
|
129 figure; imagesc(t,f,log10(abs(s)+1),[0 maxValueRangeVis(k)]); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_06_smartPhonePlayback_file%d.png',k)))
|
SebastianEwert@4
|
130 end
|
SebastianEwert@4
|
131 end
|
matthiasm@0
|
132
|
matthiasm@0
|
133 %%
|
matthiasm@0
|
134 % Some degradations delay the input signal. If some timepositions are given
|
matthiasm@0
|
135 % via timepositions_beforeDegr, the corresponding positions will be returned
|
matthiasm@0
|
136 % in timepositions_afterDegr. In this case, there is no need for f_audio
|
matthiasm@0
|
137 % and samplingFreq as above but they could be specified too.
|
matthiasm@0
|
138 timepositions_beforeDegr = [5, 60];
|
matthiasm@0
|
139 [~,timepositions_afterDegr] = applyDegradation('radioBroadcast', [], [], timepositions_beforeDegr);
|
matthiasm@0
|
140 fprintf('radioBroadcast: corresponding positions:\n');
|
matthiasm@0
|
141 for k=1:length(timepositions_beforeDegr) fprintf('%g -> %g\n',timepositions_beforeDegr(k),timepositions_afterDegr(k)); end
|
matthiasm@0
|
142
|
matthiasm@0
|
143
|
matthiasm@0
|
144
|
matthiasm@0
|
145
|
matthiasm@0
|
146
|
matthiasm@0
|
147
|
matthiasm@0
|
148
|
matthiasm@0
|
149
|
matthiasm@0
|
150
|
matthiasm@0
|
151
|