Mercurial > hg > beaglert
comparison examples/measure_noisefloor/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 extern int gBufferSize; | 15 extern int gBufferSize; |
16 | 16 |
17 using namespace std; | 17 using namespace std; |
18 | 18 |
25 // Print usage information | 25 // Print usage information |
26 void usage(const char * processName) | 26 void usage(const char * processName) |
27 { | 27 { |
28 cerr << "Usage: " << processName << " [options]" << endl; | 28 cerr << "Usage: " << processName << " [options]" << endl; |
29 | 29 |
30 BeagleRT_usage(); | 30 Bela_usage(); |
31 | 31 |
32 cerr << " --buffer-size [-b] size Set the analysis buffer size\n"; | 32 cerr << " --buffer-size [-b] size Set the analysis buffer size\n"; |
33 cerr << " --help [-h]: Print this menu\n"; | 33 cerr << " --help [-h]: Print this menu\n"; |
34 } | 34 } |
35 | 35 |
36 int main(int argc, char *argv[]) | 36 int main(int argc, char *argv[]) |
37 { | 37 { |
38 BeagleRTInitSettings settings; // Standard audio settings | 38 BelaInitSettings settings; // Standard audio settings |
39 | 39 |
40 struct option customOptions[] = | 40 struct option customOptions[] = |
41 { | 41 { |
42 {"help", 0, NULL, 'h'}, | 42 {"help", 0, NULL, 'h'}, |
43 {"buffer-size", 1, NULL, 'b'}, | 43 {"buffer-size", 1, NULL, 'b'}, |
44 {NULL, 0, NULL, 0} | 44 {NULL, 0, NULL, 0} |
45 }; | 45 }; |
46 | 46 |
47 // Set default settings | 47 // Set default settings |
48 BeagleRT_defaultSettings(&settings); | 48 Bela_defaultSettings(&settings); |
49 | 49 |
50 // By default use a longer period size because latency is not an issue | 50 // By default use a longer period size because latency is not an issue |
51 settings.periodSize = 32; | 51 settings.periodSize = 32; |
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, "hb:", customOptions, &settings)) < 0) | 56 if ((c = Bela_getopt_long(argc, argv, "hb:", customOptions, &settings)) < 0) |
57 break; | 57 break; |
58 switch (c) { | 58 switch (c) { |
59 case 'b': | 59 case 'b': |
60 gBufferSize = atoi(optarg); | 60 gBufferSize = atoi(optarg); |
61 break; | 61 break; |
71 | 71 |
72 if(gBufferSize < settings.periodSize) | 72 if(gBufferSize < settings.periodSize) |
73 gBufferSize = settings.periodSize; | 73 gBufferSize = settings.periodSize; |
74 | 74 |
75 // Initialise the PRU audio device | 75 // Initialise the PRU audio device |
76 if(BeagleRT_initAudio(&settings, 0) != 0) { | 76 if(Bela_initAudio(&settings, 0) != 0) { |
77 cout << "Error: unable to initialise audio" << endl; | 77 cout << "Error: unable to initialise audio" << endl; |
78 return -1; | 78 return -1; |
79 } | 79 } |
80 | 80 |
81 // Start the audio device running | 81 // Start the audio device running |
82 if(BeagleRT_startAudio()) { | 82 if(Bela_startAudio()) { |
83 cout << "Error: unable to start real-time audio" << endl; | 83 cout << "Error: unable to start real-time audio" << endl; |
84 return -1; | 84 return -1; |
85 } | 85 } |
86 | 86 |
87 // Set up interrupt handler to catch Control-C and SIGTERM | 87 // Set up interrupt handler to catch Control-C and SIGTERM |
92 while(!gShouldStop) { | 92 while(!gShouldStop) { |
93 usleep(100000); | 93 usleep(100000); |
94 } | 94 } |
95 | 95 |
96 // Stop the audio device | 96 // Stop the audio device |
97 BeagleRT_stopAudio(); | 97 Bela_stopAudio(); |
98 | 98 |
99 // Clean up any resources allocated for audio | 99 // Clean up any resources allocated for audio |
100 BeagleRT_cleanupAudio(); | 100 Bela_cleanupAudio(); |
101 | 101 |
102 // All done! | 102 // All done! |
103 return 0; | 103 return 0; |
104 } | 104 } |