Mercurial > hg > beaglert
comparison examples/basic_writeFile/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 // Handle Ctrl-C by requesting that the audio rendering stop | 17 // Handle Ctrl-C by requesting that the audio rendering stop |
18 void interrupt_handler(int var) | 18 void interrupt_handler(int var) |
23 // Print usage information | 23 // Print usage information |
24 void usage(const char * processName) | 24 void usage(const char * processName) |
25 { | 25 { |
26 cerr << "Usage: " << processName << " [options]" << endl; | 26 cerr << "Usage: " << processName << " [options]" << endl; |
27 | 27 |
28 BeagleRT_usage(); | 28 Bela_usage(); |
29 | 29 |
30 cerr << " --frequency [-f] frequency: Set the frequency of the oscillator\n"; | 30 cerr << " --frequency [-f] frequency: Set the frequency of the oscillator\n"; |
31 cerr << " --help [-h]: Print this menu\n"; | 31 cerr << " --help [-h]: Print this menu\n"; |
32 } | 32 } |
33 | 33 |
34 int main(int argc, char *argv[]) | 34 int main(int argc, char *argv[]) |
35 { | 35 { |
36 BeagleRTInitSettings settings; // Standard audio settings | 36 BelaInitSettings settings; // Standard audio settings |
37 float frequency = 440.0; // Frequency of oscillator | 37 float frequency = 440.0; // Frequency of oscillator |
38 | 38 |
39 struct option customOptions[] = | 39 struct option customOptions[] = |
40 { | 40 { |
41 {"help", 0, NULL, 'h'}, | 41 {"help", 0, NULL, 'h'}, |
42 {"frequency", 1, NULL, 'f'}, | 42 {"frequency", 1, NULL, 'f'}, |
43 {NULL, 0, NULL, 0} | 43 {NULL, 0, NULL, 0} |
44 }; | 44 }; |
45 | 45 |
46 // Set default settings | 46 // Set default settings |
47 BeagleRT_defaultSettings(&settings); | 47 Bela_defaultSettings(&settings); |
48 | 48 |
49 // Parse command-line arguments | 49 // Parse command-line arguments |
50 while (1) { | 50 while (1) { |
51 int c; | 51 int c; |
52 if ((c = BeagleRT_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) | 52 if ((c = Bela_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) |
53 break; | 53 break; |
54 switch (c) { | 54 switch (c) { |
55 case 'h': | 55 case 'h': |
56 usage(basename(argv[0])); | 56 usage(basename(argv[0])); |
57 exit(0); | 57 exit(0); |
64 exit(1); | 64 exit(1); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 // Initialise the PRU audio device | 68 // Initialise the PRU audio device |
69 if(BeagleRT_initAudio(&settings, &frequency) != 0) { | 69 if(Bela_initAudio(&settings, &frequency) != 0) { |
70 cout << "Error: unable to initialise audio" << endl; | 70 cout << "Error: unable to initialise audio" << endl; |
71 return -1; | 71 return -1; |
72 } | 72 } |
73 | 73 |
74 // Start the audio device running | 74 // Start the audio device running |
75 if(BeagleRT_startAudio()) { | 75 if(Bela_startAudio()) { |
76 cout << "Error: unable to start real-time audio" << endl; | 76 cout << "Error: unable to start real-time audio" << endl; |
77 return -1; | 77 return -1; |
78 } | 78 } |
79 | 79 |
80 // Set up interrupt handler to catch Control-C and SIGTERM | 80 // Set up interrupt handler to catch Control-C and SIGTERM |
85 while(!gShouldStop) { | 85 while(!gShouldStop) { |
86 usleep(100000); | 86 usleep(100000); |
87 } | 87 } |
88 | 88 |
89 // Stop the audio device | 89 // Stop the audio device |
90 BeagleRT_stopAudio(); | 90 Bela_stopAudio(); |
91 | 91 |
92 // Clean up any resources allocated for audio | 92 // Clean up any resources allocated for audio |
93 BeagleRT_cleanupAudio(); | 93 Bela_cleanupAudio(); |
94 | 94 |
95 // All done! | 95 // All done! |
96 return 0; | 96 return 0; |
97 } | 97 } |