| 283 | |
| 284 | |
| 285 | int main(const int nParams, const char * const paramStr[]) |
| 286 | { |
| 287 | WavInFile *inFile; |
| 288 | WavOutFile *outFile; |
| 289 | RunParameters *params; |
| 290 | SoundTouch soundTouch; |
| 291 | |
| 292 | fprintf(stderr, _helloText, SoundTouch::getVersionString()); |
| 293 | |
| 294 | try |
| 295 | { |
| 296 | // Parse command line parameters |
| 297 | params = new RunParameters(nParams, paramStr); |
| 298 | |
| 299 | // Open input & output files |
| 300 | openFiles(&inFile, &outFile, params); |
| 301 | |
| 302 | if (params->detectBPM == TRUE) |
| 303 | { |
| 304 | // detect sound BPM (and adjust processing parameters |
| 305 | // accordingly if necessary) |
| 306 | detectBPM(inFile, params); |
| 307 | } |
| 308 | |
| 309 | // Setup the 'SoundTouch' object for processing the sound |
| 310 | setup(&soundTouch, inFile, params); |
| 311 | |
| 312 | // clock_t cs = clock(); // for benchmarking processing duration |
| 313 | // Process the sound |
| 314 | process(&soundTouch, inFile, outFile); |
| 315 | // clock_t ce = clock(); // for benchmarking processing duration |
| 316 | // printf("duration: %lf\n", (double)(ce-cs)/CLOCKS_PER_SEC); |
| 317 | |
| 318 | // Close WAV file handles & dispose of the objects |
| 319 | delete inFile; |
| 320 | delete outFile; |
| 321 | delete params; |
| 322 | |
| 323 | fprintf(stderr, "Done!\n"); |
| 324 | } |
| 325 | catch (const runtime_error &e) |
| 326 | { |
| 327 | // An exception occurred during processing, display an error message |
| 328 | fprintf(stderr, "%s\n", e.what()); |
| 329 | return -1; |
| 330 | } |
| 331 | |
| 332 | return 0; |
| 333 | } |