Mercurial > hg > beaglert
comparison examples/d-box/main.cpp @ 301:e4392164b458 prerelease
RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 14:34:41 +0100 |
parents | dbeed520b014 |
children | 421a69d42943 |
comparison
equal
deleted
inserted
replaced
300:dbeed520b014 | 301:e4392164b458 |
---|---|
31 #include <sched.h> | 31 #include <sched.h> |
32 | 32 |
33 // get_opt_long | 33 // get_opt_long |
34 #include <getopt.h> | 34 #include <getopt.h> |
35 | 35 |
36 #include <BeagleRT.h> | 36 #include <Bela.h> |
37 #include "config.h" | 37 #include "config.h" |
38 #include "sensors.h" | 38 #include "sensors.h" |
39 #include "OscillatorBank.h" | 39 #include "OscillatorBank.h" |
40 #include "StatusLED.h" | 40 #include "StatusLED.h" |
41 #include "logger.h" | 41 #include "logger.h" |
260 | 260 |
261 gShouldStop = true; | 261 gShouldStop = true; |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 void parseArguments(arg_data args, BeagleRTInitSettings *settings) | 265 void parseArguments(arg_data args, BelaInitSettings *settings) |
266 { | 266 { |
267 // Default filename; | 267 // Default filename; |
268 gPartialFilename = strdup("D-Box_sound_250_60_40_h88_2.txt"); | 268 gPartialFilename = strdup("D-Box_sound_250_60_40_h88_2.txt"); |
269 | 269 |
270 const int kOptionAudioTest = 1000; | 270 const int kOptionAudioTest = 1000; |
288 {NULL, 0, NULL, 0}, | 288 {NULL, 0, NULL, 0}, |
289 }; | 289 }; |
290 int morehelp = 0; | 290 int morehelp = 0; |
291 int tmp = -1; | 291 int tmp = -1; |
292 | 292 |
293 BeagleRT_defaultSettings(settings); | 293 Bela_defaultSettings(settings); |
294 | 294 |
295 while (1) | 295 while (1) |
296 { | 296 { |
297 int c; | 297 int c; |
298 if ((c = BeagleRT_getopt_long(args.argc, args.argv, "hf:ki:sq:r:t:l:u:o:n:g:", long_option, settings)) < 0) | 298 if ((c = Bela_getopt_long(args.argc, args.argv, "hf:ki:sq:r:t:l:u:o:n:g:", long_option, settings)) < 0) |
299 break; | 299 break; |
300 switch (c) | 300 switch (c) |
301 { | 301 { |
302 case 'h': | 302 case 'h': |
303 morehelp++; | 303 morehelp++; |
361 gVerbose = settings->verbose; | 361 gVerbose = settings->verbose; |
362 } | 362 } |
363 | 363 |
364 int main(int argc, char *argv[]) | 364 int main(int argc, char *argv[]) |
365 { | 365 { |
366 BeagleRTInitSettings settings; // Standard audio settings | 366 BelaInitSettings settings; // Standard audio settings |
367 RT_TASK rtSensorThread; | 367 RT_TASK rtSensorThread; |
368 const char rtSensorThreadName[] = "dbox-sensor"; | 368 const char rtSensorThreadName[] = "dbox-sensor"; |
369 int oscBankHopSize; | 369 int oscBankHopSize; |
370 | 370 |
371 // Parse command-line arguments | 371 // Parse command-line arguments |
372 args.argc = argc; | 372 args.argc = argc; |
373 args.argv = argv; | 373 args.argv = argv; |
374 parseArguments(args, &settings); | 374 parseArguments(args, &settings); |
375 | 375 |
376 BeagleRT_setVerboseLevel(gVerbose); | 376 Bela_setVerboseLevel(gVerbose); |
377 if(gVerbose == 1 && useAudioTest) | 377 if(gVerbose == 1 && useAudioTest) |
378 cout << "main() : running in audio test mode" << endl; | 378 cout << "main() : running in audio test mode" << endl; |
379 | 379 |
380 // Load sound files from directory | 380 // Load sound files from directory |
381 if(initSoundFiles() != 0) | 381 if(initSoundFiles() != 0) |
382 return -1; | 382 return -1; |
383 | 383 |
384 oscBankHopSize = gOscBanks[gCurrentOscBank]->getHopSize()/gOscBanks[gCurrentOscBank]->getMinSpeed(); | 384 oscBankHopSize = gOscBanks[gCurrentOscBank]->getHopSize()/gOscBanks[gCurrentOscBank]->getMinSpeed(); |
385 | 385 |
386 // Initialise the audio device | 386 // Initialise the audio device |
387 if(BeagleRT_initAudio(&settings, &oscBankHopSize) != 0) | 387 if(Bela_initAudio(&settings, &oscBankHopSize) != 0) |
388 return -1; | 388 return -1; |
389 | 389 |
390 // Initialise the status LED | 390 // Initialise the status LED |
391 if(!gStatusLED.init(kStatusLEDPin)) { | 391 if(!gStatusLED.init(kStatusLEDPin)) { |
392 if(gVerbose) | 392 if(gVerbose) |
403 } | 403 } |
404 | 404 |
405 if(gVerbose == 1) | 405 if(gVerbose == 1) |
406 cout << "main() : creating audio thread" << endl; | 406 cout << "main() : creating audio thread" << endl; |
407 | 407 |
408 if(BeagleRT_startAudio()) { | 408 if(Bela_startAudio()) { |
409 cout << "Error: unable to start real-time audio" << endl; | 409 cout << "Error: unable to start real-time audio" << endl; |
410 return -1; | 410 return -1; |
411 } | 411 } |
412 | 412 |
413 // LED on... | 413 // LED on... |
464 // Run until told to stop | 464 // Run until told to stop |
465 while(!gShouldStop) { | 465 while(!gShouldStop) { |
466 usleep(100000); | 466 usleep(100000); |
467 } | 467 } |
468 | 468 |
469 BeagleRT_stopAudio(); | 469 Bela_stopAudio(); |
470 | 470 |
471 if(!useAudioTest) | 471 if(!useAudioTest) |
472 rt_task_join(&rtSensorThread); | 472 rt_task_join(&rtSensorThread); |
473 | 473 |
474 BeagleRT_cleanupAudio(); | 474 Bela_cleanupAudio(); |
475 | 475 |
476 pthread_join( keyboardThread, NULL); | 476 pthread_join( keyboardThread, NULL); |
477 pthread_join( logThread, NULL); | 477 pthread_join( logThread, NULL); |
478 | 478 |
479 for(unsigned int i = 0; i < gOscBanks.size(); i++) | 479 for(unsigned int i = 0; i < gOscBanks.size(); i++) |