comparison modules-and-plug-ins/python-module/btrack_python_module.cpp @ 54:9699024bb3d0

Before this commit, the OnsetDetectionFunction class used double precision, and the BTrack class used floats. I have now made BTrack use double precision also. This works fine and the only cost of doing this is that we have to perform one array copy into floating point format so that sample rate conversion (which has to be in floating point format) can take place.
author Adam Stark <adamstark@users.noreply.github.com>
date Wed, 22 Jan 2014 02:49:29 +0000
parents 45231107c9d6
children 450c53430540
comparison
equal deleted inserted replaced
53:338f5eb29e41 54:9699024bb3d0
154 //b.setparams(0.9,5); 154 //b.setparams(0.9,5);
155 155
156 double df[numframes]; 156 double df[numframes];
157 double beats[5000]; 157 double beats[5000];
158 int beatnum = 0; 158 int beatnum = 0;
159 float df_val; 159
160 double df_val;
160 161
161 /////////////////////////////////////////// 162 ///////////////////////////////////////////
162 //////// Begin Processing Loop //////////// 163 //////// Begin Processing Loop ////////////
163 164
164 for (int i=0;i < numframes;i++) 165 for (int i=0;i < numframes;i++)
169 buffer[n] = data[(i*hsize)+n]; 170 buffer[n] = data[(i*hsize)+n];
170 } 171 }
171 172
172 df[i] = onset.getDFsample(buffer); 173 df[i] = onset.getDFsample(buffer);
173 174
174 df_val = (float) (df[i] + 0.0001); 175 df_val = df[i] + 0.0001;
175 176
176 b.process(df_val); // process df sample in beat tracker 177 b.process(df_val); // process df sample in beat tracker
177 178
178 if (b.playbeat == 1) 179 if (b.playbeat == 1)
179 { 180 {
268 // set parameters 269 // set parameters
269 //b.setparams(0.9,5); 270 //b.setparams(0.9,5);
270 271
271 double beats[5000]; 272 double beats[5000];
272 int beatnum = 0; 273 int beatnum = 0;
273 float df_val; 274 double df_val;
274 275
275 /////////////////////////////////////////// 276 ///////////////////////////////////////////
276 //////// Begin Processing Loop //////////// 277 //////// Begin Processing Loop ////////////
277 278
278 for (long i=0;i < numframes;i++) 279 for (long i=0;i < numframes;i++)
279 { 280 {
280 df_val = (float) (data[i] + 0.0001); 281 df_val = data[i] + 0.0001;
281 282
282 b.process(df_val); // process df sample in beat tracker 283 b.process(df_val); // process df sample in beat tracker
283 284
284 if (b.playbeat == 1) 285 if (b.playbeat == 1)
285 { 286 {