comparison examples/analogDigitalDemo/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
16 #include <getopt.h> 16 #include <getopt.h>
17 #include <unistd.h> 17 #include <unistd.h>
18 #include <stdlib.h> 18 #include <stdlib.h>
19 #include <fcntl.h> 19 #include <fcntl.h>
20 20
21 #include <BeagleRT.h> 21 #include <Bela.h>
22 22
23 using namespace std; 23 using namespace std;
24 24
25 // Handle Ctrl-C by requesting that the audio rendering stop 25 // Handle Ctrl-C by requesting that the audio rendering stop
26 void interrupt_handler(int var) 26 void interrupt_handler(int var)
31 // Print usage information 31 // Print usage information
32 void usage(const char * processName) 32 void usage(const char * processName)
33 { 33 {
34 cerr << "Usage: " << processName << " [options]" << endl; 34 cerr << "Usage: " << processName << " [options]" << endl;
35 35
36 BeagleRT_usage(); 36 Bela_usage();
37 37
38 cerr << " --help [-h]: Print this menu\n"; 38 cerr << " --help [-h]: Print this menu\n";
39 } 39 }
40 40
41 int main(int argc, char *argv[]) 41 int main(int argc, char *argv[])
42 { 42 {
43 BeagleRTInitSettings settings; // Standard audio settings 43 BelaInitSettings settings; // Standard audio settings
44 float frequency = 1000.0; // Frequency of crossover 44 float frequency = 1000.0; // Frequency of crossover
45 45
46 struct option customOptions[] = 46 struct option customOptions[] =
47 { 47 {
48 {"help", 0, NULL, 'h'}, 48 {"help", 0, NULL, 'h'},
49 {"frequency", 1, NULL, 'f'}, 49 {"frequency", 1, NULL, 'f'},
50 {NULL, 0, NULL, 0} 50 {NULL, 0, NULL, 0}
51 }; 51 };
52 52
53 // Set default settings 53 // Set default settings
54 BeagleRT_defaultSettings(&settings); 54 Bela_defaultSettings(&settings);
55 55
56 // Parse command-line arguments 56 // Parse command-line arguments
57 while (1) { 57 while (1) {
58 int c; 58 int c;
59 if ((c = BeagleRT_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) 59 if ((c = Bela_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0)
60 break; 60 break;
61 switch (c) { 61 switch (c) {
62 case 'h': 62 case 'h':
63 usage(basename(argv[0])); 63 usage(basename(argv[0]));
64 exit(0); 64 exit(0);
75 exit(1); 75 exit(1);
76 } 76 }
77 } 77 }
78 78
79 // Initialise the PRU audio device 79 // Initialise the PRU audio device
80 if(BeagleRT_initAudio(&settings, &frequency) != 0) { 80 if(Bela_initAudio(&settings, &frequency) != 0) {
81 cout << "Error: unable to initialise audio" << endl; 81 cout << "Error: unable to initialise audio" << endl;
82 return -1; 82 return -1;
83 } 83 }
84 84
85 // Start the audio device running 85 // Start the audio device running
86 if(BeagleRT_startAudio()) { 86 if(Bela_startAudio()) {
87 cout << "Error: unable to start real-time audio" << endl; 87 cout << "Error: unable to start real-time audio" << endl;
88 return -1; 88 return -1;
89 } 89 }
90 90
91 // Set up interrupt handler to catch Control-C 91 // Set up interrupt handler to catch Control-C
96 while(!gShouldStop) { 96 while(!gShouldStop) {
97 usleep(100000); 97 usleep(100000);
98 } 98 }
99 99
100 // Stop the audio device 100 // Stop the audio device
101 BeagleRT_stopAudio(); 101 Bela_stopAudio();
102 102
103 // Clean up any resources allocated for audio 103 // Clean up any resources allocated for audio
104 BeagleRT_cleanupAudio(); 104 Bela_cleanupAudio();
105 105
106 // All done! 106 // All done!
107 return 0; 107 return 0;
108 } 108 }