Mercurial > hg > beaglert
comparison examples/samples/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 |
---|---|
11 #include <signal.h> | 11 #include <signal.h> |
12 #include <string> | 12 #include <string> |
13 #include <getopt.h> | 13 #include <getopt.h> |
14 #include <sndfile.h> // to load audio files | 14 #include <sndfile.h> // to load audio files |
15 | 15 |
16 #include <BeagleRT.h> | 16 #include <Bela.h> |
17 #include "SampleData.h" | 17 #include "SampleData.h" |
18 | 18 |
19 using namespace std; | 19 using namespace std; |
20 | 20 |
21 // Load samples from file | 21 // Load samples from file |
81 // Print usage information | 81 // Print usage information |
82 void usage(const char * processName) | 82 void usage(const char * processName) |
83 { | 83 { |
84 cerr << "Usage: " << processName << " [options]" << endl; | 84 cerr << "Usage: " << processName << " [options]" << endl; |
85 | 85 |
86 BeagleRT_usage(); | 86 Bela_usage(); |
87 | 87 |
88 cerr << " --file [-f] filename: Name of the file to load (default is \"sample.wav\")\n"; | 88 cerr << " --file [-f] filename: Name of the file to load (default is \"sample.wav\")\n"; |
89 cerr << " --help [-h]: Print this menu\n"; | 89 cerr << " --help [-h]: Print this menu\n"; |
90 } | 90 } |
91 | 91 |
92 int main(int argc, char *argv[]) | 92 int main(int argc, char *argv[]) |
93 { | 93 { |
94 BeagleRTInitSettings settings; // Standard audio settings | 94 BelaInitSettings settings; // Standard audio settings |
95 string fileName; // Name of the sample to load | 95 string fileName; // Name of the sample to load |
96 | 96 |
97 SampleData sampleData; // User define structure to pass data retrieved from file to render function | 97 SampleData sampleData; // User define structure to pass data retrieved from file to render function |
98 sampleData.samples = 0; | 98 sampleData.samples = 0; |
99 sampleData.sampleLen = -1; | 99 sampleData.sampleLen = -1; |
105 {"file", 1, NULL, 'f'}, | 105 {"file", 1, NULL, 'f'}, |
106 {NULL, 0, NULL, 0} | 106 {NULL, 0, NULL, 0} |
107 }; | 107 }; |
108 | 108 |
109 // Set default settings | 109 // Set default settings |
110 BeagleRT_defaultSettings(&settings); | 110 Bela_defaultSettings(&settings); |
111 | 111 |
112 // Parse command-line arguments | 112 // Parse command-line arguments |
113 while (1) { | 113 while (1) { |
114 int c; | 114 int c; |
115 if ((c = BeagleRT_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) | 115 if ((c = Bela_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) |
116 break; | 116 break; |
117 switch (c) { | 117 switch (c) { |
118 case 'h': | 118 case 'h': |
119 usage(basename(argv[0])); | 119 usage(basename(argv[0])); |
120 exit(0); | 120 exit(0); |
146 if(settings.verbose) | 146 if(settings.verbose) |
147 cout << "File contains " << sampleData.sampleLen << " samples" << endl; | 147 cout << "File contains " << sampleData.sampleLen << " samples" << endl; |
148 | 148 |
149 | 149 |
150 // Initialise the PRU audio device | 150 // Initialise the PRU audio device |
151 if(BeagleRT_initAudio(&settings, &sampleData) != 0) { | 151 if(Bela_initAudio(&settings, &sampleData) != 0) { |
152 cout << "Error: unable to initialise audio" << endl; | 152 cout << "Error: unable to initialise audio" << endl; |
153 return -1; | 153 return -1; |
154 } | 154 } |
155 | 155 |
156 // Start the audio device running | 156 // Start the audio device running |
157 if(BeagleRT_startAudio()) { | 157 if(Bela_startAudio()) { |
158 cout << "Error: unable to start real-time audio" << endl; | 158 cout << "Error: unable to start real-time audio" << endl; |
159 return -1; | 159 return -1; |
160 } | 160 } |
161 | 161 |
162 // Set up interrupt handler to catch Control-C and SIGTERM | 162 // Set up interrupt handler to catch Control-C and SIGTERM |
167 while(!gShouldStop) { | 167 while(!gShouldStop) { |
168 usleep(100000); | 168 usleep(100000); |
169 } | 169 } |
170 | 170 |
171 // Stop the audio device | 171 // Stop the audio device |
172 BeagleRT_stopAudio(); | 172 Bela_stopAudio(); |
173 | 173 |
174 // Clean up any resources allocated for audio | 174 // Clean up any resources allocated for audio |
175 BeagleRT_cleanupAudio(); | 175 Bela_cleanupAudio(); |
176 | 176 |
177 // All done! | 177 // All done! |
178 return 0; | 178 return 0; |
179 } | 179 } |