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@0
|
25 addpath(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';
|
SebastianEwert@4
|
36 };
|
matthiasm@0
|
37
|
SebastianEwert@4
|
38 createSpectrograms = 0;
|
matthiasm@0
|
39
|
matthiasm@0
|
40 %%
|
SebastianEwert@4
|
41 % just copying original files to the demo folder
|
SebastianEwert@4
|
42 for k=1:length(filenames)
|
SebastianEwert@4
|
43 copyfile(filenames{k}, fullfile(pathOutputDemo,sprintf('00_Original_file%d.wav',k)))
|
SebastianEwert@4
|
44 if createSpectrograms
|
SebastianEwert@4
|
45 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
46 [s,f,t] = spectrogram(f_audio,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
47 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@4
|
48 end
|
SebastianEwert@4
|
49 end
|
matthiasm@0
|
50
|
matthiasm@0
|
51 %%
|
SebastianEwert@4
|
52 for k=1:length(filenames)
|
SebastianEwert@4
|
53 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
54
|
SebastianEwert@4
|
55 f_audio_out = applyDegradation('liveRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
56
|
SebastianEwert@4
|
57 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_01_liveRecording_file%d.wav',k)));
|
SebastianEwert@4
|
58 if createSpectrograms
|
SebastianEwert@4
|
59 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
60 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_01_liveRecording_file%d.png',k)))
|
SebastianEwert@4
|
61 end
|
SebastianEwert@4
|
62 end
|
matthiasm@0
|
63
|
matthiasm@0
|
64 %%
|
SebastianEwert@4
|
65 for k=1:length(filenames)
|
SebastianEwert@4
|
66 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
67
|
SebastianEwert@4
|
68 f_audio_out = applyDegradation('strongMp3Compression', f_audio, samplingFreq);
|
SebastianEwert@4
|
69
|
SebastianEwert@4
|
70 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_02_strongMp3Compression_file%d.wav',k)));
|
SebastianEwert@4
|
71 if createSpectrograms
|
SebastianEwert@4
|
72 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
73 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_02_strongMp3Compression_file%d.png',k)))
|
SebastianEwert@4
|
74 end
|
SebastianEwert@4
|
75 end
|
matthiasm@0
|
76
|
matthiasm@0
|
77 %%
|
SebastianEwert@4
|
78 for k=1:length(filenames)
|
SebastianEwert@4
|
79 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
80
|
SebastianEwert@4
|
81 f_audio_out = applyDegradation('vinylRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
82
|
SebastianEwert@4
|
83 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_03_vinylRecording_file%d.wav',k)));
|
SebastianEwert@4
|
84 if createSpectrograms
|
SebastianEwert@4
|
85 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
86 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_03_vinylRecording_file%d.png',k)))
|
SebastianEwert@4
|
87 end
|
SebastianEwert@4
|
88 end
|
matthiasm@0
|
89
|
matthiasm@0
|
90 %%
|
SebastianEwert@4
|
91 for k=1:length(filenames)
|
SebastianEwert@4
|
92 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
93
|
SebastianEwert@4
|
94 f_audio_out = applyDegradation('radioBroadcast', f_audio, samplingFreq);
|
SebastianEwert@4
|
95
|
SebastianEwert@4
|
96 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_04_radioBroadcast_file%d.wav',k)));
|
SebastianEwert@4
|
97 if createSpectrograms
|
SebastianEwert@4
|
98 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
99 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_04_radioBroadcast_file%d.png',k)))
|
SebastianEwert@4
|
100 end
|
SebastianEwert@4
|
101 end
|
matthiasm@0
|
102
|
SebastianEwert@4
|
103 %%
|
SebastianEwert@4
|
104 for k=1:length(filenames)
|
SebastianEwert@4
|
105 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
106
|
SebastianEwert@4
|
107 f_audio_out = applyDegradation('smartPhoneRecording', f_audio, samplingFreq);
|
SebastianEwert@4
|
108
|
SebastianEwert@4
|
109 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_05_smartPhoneRecording_file%d.wav',k)));
|
SebastianEwert@4
|
110 if createSpectrograms
|
SebastianEwert@4
|
111 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
112 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_05_smartPhoneRecording_file%d.png',k)))
|
SebastianEwert@4
|
113 end
|
SebastianEwert@4
|
114 end
|
matthiasm@0
|
115
|
SebastianEwert@4
|
116 %%
|
SebastianEwert@4
|
117 for k=1:length(filenames)
|
SebastianEwert@4
|
118 [f_audio,samplingFreq]=wavread(filenames{k});
|
SebastianEwert@4
|
119
|
SebastianEwert@4
|
120 f_audio_out = applyDegradation('smartPhonePlayback', f_audio, samplingFreq);
|
SebastianEwert@4
|
121
|
SebastianEwert@4
|
122 wavwrite(f_audio_out,samplingFreq,16,fullfile(pathOutputDemo,sprintf('Degr_06_smartPhonePlayback_file%d.wav',k)));
|
SebastianEwert@4
|
123 if createSpectrograms
|
SebastianEwert@4
|
124 [s,f,t] = spectrogram(f_audio_out,hamming(round(samplingFreq*0.093)),round(samplingFreq*0.093/2),[],samplingFreq);
|
SebastianEwert@4
|
125 figure; imagesc(t,f,log10(abs(s)+1)); axis xy; colormap(hot); ylim([0,8000]); colorbar; print('-dpng', fullfile(pathOutputDemo,sprintf('Degr_06_smartPhonePlayback_file%d.png',k)))
|
SebastianEwert@4
|
126 end
|
SebastianEwert@4
|
127 end
|
matthiasm@0
|
128
|
matthiasm@0
|
129 %%
|
matthiasm@0
|
130 % Some degradations delay the input signal. If some timepositions are given
|
matthiasm@0
|
131 % via timepositions_beforeDegr, the corresponding positions will be returned
|
matthiasm@0
|
132 % in timepositions_afterDegr. In this case, there is no need for f_audio
|
matthiasm@0
|
133 % and samplingFreq as above but they could be specified too.
|
matthiasm@0
|
134 timepositions_beforeDegr = [5, 60];
|
matthiasm@0
|
135 [~,timepositions_afterDegr] = applyDegradation('radioBroadcast', [], [], timepositions_beforeDegr);
|
matthiasm@0
|
136 fprintf('radioBroadcast: corresponding positions:\n');
|
matthiasm@0
|
137 for k=1:length(timepositions_beforeDegr) fprintf('%g -> %g\n',timepositions_beforeDegr(k),timepositions_afterDegr(k)); end
|
matthiasm@0
|
138
|
matthiasm@0
|
139
|
matthiasm@0
|
140
|
matthiasm@0
|
141
|
matthiasm@0
|
142
|
matthiasm@0
|
143
|
matthiasm@0
|
144
|
matthiasm@0
|
145
|
matthiasm@0
|
146
|
matthiasm@0
|
147
|