Mercurial > hg > beaglert
comparison examples/oscillator_bank/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 |
comparison
equal
deleted
inserted
replaced
300:dbeed520b014 | 301:e4392164b458 |
---|---|
8 #include <iostream> | 8 #include <iostream> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 #include <libgen.h> | 10 #include <libgen.h> |
11 #include <signal.h> | 11 #include <signal.h> |
12 #include <getopt.h> | 12 #include <getopt.h> |
13 #include <BeagleRT.h> | 13 #include <Bela.h> |
14 | 14 |
15 using namespace std; | 15 using namespace std; |
16 | 16 |
17 int gNumOscillators = 32; | 17 int gNumOscillators = 32; |
18 int gWavetableLength = 1024; | 18 int gWavetableLength = 1024; |
26 // Print usage information | 26 // Print usage information |
27 void usage(const char * processName) | 27 void usage(const char * processName) |
28 { | 28 { |
29 cerr << "Usage: " << processName << " [options]" << endl; | 29 cerr << "Usage: " << processName << " [options]" << endl; |
30 | 30 |
31 BeagleRT_usage(); | 31 Bela_usage(); |
32 | 32 |
33 cerr << " --num-oscillators [-n] oscs: Set the number of oscillators to use (default: 32)\n"; | 33 cerr << " --num-oscillators [-n] oscs: Set the number of oscillators to use (default: 32)\n"; |
34 cerr << " --wavetable [-w] length: Set the wavetable length in samples (default: 1024)\n"; | 34 cerr << " --wavetable [-w] length: Set the wavetable length in samples (default: 1024)\n"; |
35 cerr << " --help [-h]: Print this menu\n"; | 35 cerr << " --help [-h]: Print this menu\n"; |
36 } | 36 } |
37 | 37 |
38 int main(int argc, char *argv[]) | 38 int main(int argc, char *argv[]) |
39 { | 39 { |
40 BeagleRTInitSettings settings; // Standard audio settings | 40 BelaInitSettings settings; // Standard audio settings |
41 | 41 |
42 struct option customOptions[] = | 42 struct option customOptions[] = |
43 { | 43 { |
44 {"help", 0, NULL, 'h'}, | 44 {"help", 0, NULL, 'h'}, |
45 {"num-oscillators", 1, NULL, 'n'}, | 45 {"num-oscillators", 1, NULL, 'n'}, |
46 {"wavetable", 1, NULL, 'w'}, | 46 {"wavetable", 1, NULL, 'w'}, |
47 {NULL, 0, NULL, 0} | 47 {NULL, 0, NULL, 0} |
48 }; | 48 }; |
49 | 49 |
50 // Set default settings | 50 // Set default settings |
51 BeagleRT_defaultSettings(&settings); | 51 Bela_defaultSettings(&settings); |
52 | 52 |
53 // Parse command-line arguments | 53 // Parse command-line arguments |
54 while (1) { | 54 while (1) { |
55 int c; | 55 int c; |
56 if ((c = BeagleRT_getopt_long(argc, argv, "hn:w:", customOptions, &settings)) < 0) | 56 if ((c = Bela_getopt_long(argc, argv, "hn:w:", customOptions, &settings)) < 0) |
57 break; | 57 break; |
58 switch (c) { | 58 switch (c) { |
59 case 'h': | 59 case 'h': |
60 usage(basename(argv[0])); | 60 usage(basename(argv[0])); |
61 exit(0); | 61 exit(0); |
79 exit(1); | 79 exit(1); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 // Initialise the PRU audio device | 83 // Initialise the PRU audio device |
84 if(BeagleRT_initAudio(&settings, 0) != 0) { | 84 if(Bela_initAudio(&settings, 0) != 0) { |
85 cout << "Error: unable to initialise audio" << endl; | 85 cout << "Error: unable to initialise audio" << endl; |
86 return -1; | 86 return -1; |
87 } | 87 } |
88 | 88 |
89 if(settings.verbose) { | 89 if(settings.verbose) { |
90 cout << "--> Using " << gNumOscillators << " oscillators and wavetable of " << gWavetableLength << " samples\n"; | 90 cout << "--> Using " << gNumOscillators << " oscillators and wavetable of " << gWavetableLength << " samples\n"; |
91 } | 91 } |
92 | 92 |
93 // Start the audio device running | 93 // Start the audio device running |
94 if(BeagleRT_startAudio()) { | 94 if(Bela_startAudio()) { |
95 cout << "Error: unable to start real-time audio" << endl; | 95 cout << "Error: unable to start real-time audio" << endl; |
96 return -1; | 96 return -1; |
97 } | 97 } |
98 | 98 |
99 // Set up interrupt handler to catch Control-C and SIGTERM | 99 // Set up interrupt handler to catch Control-C and SIGTERM |
104 while(!gShouldStop) { | 104 while(!gShouldStop) { |
105 usleep(100000); | 105 usleep(100000); |
106 } | 106 } |
107 | 107 |
108 // Stop the audio device | 108 // Stop the audio device |
109 BeagleRT_stopAudio(); | 109 Bela_stopAudio(); |
110 | 110 |
111 // Clean up any resources allocated for audio | 111 // Clean up any resources allocated for audio |
112 BeagleRT_cleanupAudio(); | 112 Bela_cleanupAudio(); |
113 | 113 |
114 // All done! | 114 // All done! |
115 return 0; | 115 return 0; |
116 } | 116 } |