Mercurial > hg > beaglert
comparison examples/audio_in_FFT/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 << " --fftsize [-s] size: Set the fSize of the FFT, in samples\n"; | 30 cerr << " --fftsize [-s] size: Set the fSize of the FFT, in samples\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 int fftSize = 64; // Size of the FFT, in samples | 37 int fftSize = 64; // Size of the FFT, in samples |
38 | 38 |
39 struct option customOptions[] = | 39 struct option customOptions[] = |
40 { | 40 { |
41 {"help", 0, NULL, 'h'}, | 41 {"help", 0, NULL, 'h'}, |
42 {"fftsize", 1, NULL, 's'}, | 42 {"fftsize", 1, NULL, 's'}, |
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 // settings.useAnalog = 0; // No matrix usage by default | 49 // settings.useAnalog = 0; // No matrix usage by default |
50 | 50 |
51 // Parse command-line arguments | 51 // Parse command-line arguments |
52 while (1) { | 52 while (1) { |
53 int c; | 53 int c; |
54 if ((c = BeagleRT_getopt_long(argc, argv, "hs:", customOptions, &settings)) < 0) | 54 if ((c = Bela_getopt_long(argc, argv, "hs:", customOptions, &settings)) < 0) |
55 break; | 55 break; |
56 switch (c) { | 56 switch (c) { |
57 case 'h': | 57 case 'h': |
58 usage(basename(argv[0])); | 58 usage(basename(argv[0])); |
59 exit(0); | 59 exit(0); |
66 exit(1); | 66 exit(1); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 // Initialise the PRU audio device | 70 // Initialise the PRU audio device |
71 if(BeagleRT_initAudio(&settings, &fftSize) != 0) { | 71 if(Bela_initAudio(&settings, &fftSize) != 0) { |
72 cout << "Error: unable to initialise audio" << endl; | 72 cout << "Error: unable to initialise audio" << endl; |
73 return -1; | 73 return -1; |
74 } | 74 } |
75 | 75 |
76 // Start the audio device running | 76 // Start the audio device running |
77 if(BeagleRT_startAudio()) { | 77 if(Bela_startAudio()) { |
78 cout << "Error: unable to start real-time audio" << endl; | 78 cout << "Error: unable to start real-time audio" << endl; |
79 return -1; | 79 return -1; |
80 } | 80 } |
81 | 81 |
82 // Set up interrupt handler to catch Control-C and SIGTERM | 82 // Set up interrupt handler to catch Control-C and SIGTERM |
87 while(!gShouldStop) { | 87 while(!gShouldStop) { |
88 usleep(100000); | 88 usleep(100000); |
89 } | 89 } |
90 | 90 |
91 // Stop the audio device | 91 // Stop the audio device |
92 BeagleRT_stopAudio(); | 92 Bela_stopAudio(); |
93 | 93 |
94 // Clean up any resources allocated for audio | 94 // Clean up any resources allocated for audio |
95 BeagleRT_cleanupAudio(); | 95 Bela_cleanupAudio(); |
96 | 96 |
97 // All done! | 97 // All done! |
98 return 0; | 98 return 0; |
99 } | 99 } |
100 | 100 |