Mercurial > hg > audio-degradation-toolbox
comparison demo_batchProcessing.m @ 13:1a058eb51073
degradation folder re-sort; towards more comprehensive batch processing demo
author | matthiasm |
---|---|
date | Thu, 24 Oct 2013 20:26:35 +0100 |
parents | 9d682f5e3927 |
children | c3a002ed2815 |
comparison
equal
deleted
inserted
replaced
12:59f4c7548a9e | 13:1a058eb51073 |
---|---|
16 % License, or (at your option) any later version. See the file | 16 % License, or (at your option) any later version. See the file |
17 % COPYING included with this distribution for more information. | 17 % COPYING included with this distribution for more information. |
18 % | 18 % |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
20 | 20 |
21 addpath(fullfile(pwd,'AudioDegradationToolbox')); | 21 addpath(genpath(fullfile(pwd,'AudioDegradationToolbox'))); |
22 | 22 |
23 % the following file should list all the files to process. Every line | 23 % the following file should list all the files to process. Every line |
24 % should specify one audio file, one audio file and a ground truth file in | 24 % should specify one audio file, one audio file and a ground truth file in |
25 % CSV format, or just the ground truth file. This example scripts treats | 25 % CSV format, or just the ground truth file. This example scripts treats |
26 % the first column of a CSV file as time information that needs to be | 26 % the first column of a CSV file as time information that needs to be |
37 % at the same time, line 5: process only ground truth data | 37 % at the same time, line 5: process only ground truth data |
38 | 38 |
39 % destination directory | 39 % destination directory |
40 outputDirectory = 'demoOutput/'; | 40 outputDirectory = 'demoOutput/'; |
41 | 41 |
42 % desired degradations | |
43 degradationnames = {'liveRecording', ... | |
44 'pubEnvironment', ... | |
45 'radioBroadcast', ... | |
46 'smartPhonePlayback', ... | |
47 'smartPhoneRecording', ... | |
48 'strongMp3Compression', ... | |
49 'vinylRecording', ... | |
50 'unit_addSound', ... | |
51 'unit_addNoise'}; | |
52 nDegradation = length(degradationnames); | |
42 | 53 |
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
46 | 57 |
104 | 115 |
105 timepositions_beforeDegr = data{1}; | 116 timepositions_beforeDegr = data{1}; |
106 remainingColumns = data{2}; | 117 remainingColumns = data{2}; |
107 end | 118 end |
108 | 119 |
109 % Start the degradation process | 120 % apply degradations |
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
111 degradationname = 'liveRecording'; | 122 for iDegradation = 1:nDegradation |
112 PathToOutput = fullfile(outputDirectory,degradationname); | 123 degradationname = degradationnames{iDegradation}; |
113 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | 124 PathToOutput = fullfile(outputDirectory,degradationname); |
114 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | 125 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end |
115 | 126 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); |
116 if ~isempty(audiofilename) | 127 |
117 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | 128 if ~isempty(audiofilename) |
129 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
130 end | |
131 if ~isempty(csvfilename) | |
132 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
133 end | |
118 end | 134 end |
119 if ~isempty(csvfilename) | |
120 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
121 end | |
122 | |
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
124 degradationname = 'strongMp3Compression'; | |
125 PathToOutput = fullfile(outputDirectory,degradationname); | |
126 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | |
127 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | |
128 | |
129 if ~isempty(audiofilename) | |
130 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
131 end | |
132 if ~isempty(csvfilename) | |
133 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
134 end | |
135 | |
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
137 degradationname = 'vinylRecording'; | |
138 PathToOutput = fullfile(outputDirectory,degradationname); | |
139 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | |
140 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | |
141 | |
142 if ~isempty(audiofilename) | |
143 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
144 end | |
145 if ~isempty(csvfilename) | |
146 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
147 end | |
148 | |
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
150 degradationname = 'radioBroadcast'; | |
151 PathToOutput = fullfile(outputDirectory,degradationname); | |
152 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | |
153 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | |
154 | |
155 if ~isempty(audiofilename) | |
156 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
157 end | |
158 if ~isempty(csvfilename) | |
159 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
160 end | |
161 | |
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
163 degradationname = 'smartPhoneRecording'; | |
164 PathToOutput = fullfile(outputDirectory,degradationname); | |
165 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | |
166 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | |
167 | |
168 if ~isempty(audiofilename) | |
169 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
170 end | |
171 if ~isempty(csvfilename) | |
172 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
173 end | |
174 | |
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
176 degradationname = 'smartPhonePlayback'; | |
177 PathToOutput = fullfile(outputDirectory,degradationname); | |
178 if ~exist(PathToOutput,'dir') mkdir(PathToOutput); end | |
179 [f_audio_out,timepositions_afterDegr] = applyDegradation(degradationname, f_audio, samplingFreq, timepositions_beforeDegr); | |
180 | |
181 if ~isempty(audiofilename) | |
182 wavwrite(f_audio_out,samplingFreq,nbits,fullfile(PathToOutput,audiofilename)); | |
183 end | |
184 if ~isempty(csvfilename) | |
185 writeCsvFile(fullfile(PathToOutput,csvfilename),timepositions_afterDegr,remainingColumns); | |
186 end | |
187 | |
188 end | 135 end |
189 | 136 |
190 end | 137 end |
191 | 138 |
192 | 139 |