Mercurial > hg > beaglert
comparison examples/filter_IIR/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 float gCutFreq = 100; | 21 float gCutFreq = 100; |
82 // Print usage information | 82 // Print usage information |
83 void usage(const char * processName) | 83 void usage(const char * processName) |
84 { | 84 { |
85 cerr << "Usage: " << processName << " [options]" << endl; | 85 cerr << "Usage: " << processName << " [options]" << endl; |
86 | 86 |
87 BeagleRT_usage(); | 87 Bela_usage(); |
88 | 88 |
89 cerr << " --file [-f] filename: Name of the file to load (default is \"longsample.wav\")\n"; | 89 cerr << " --file [-f] filename: Name of the file to load (default is \"longsample.wav\")\n"; |
90 cerr << " --cutfreq [-c] freq: Set the cut off frequency of the filter in Hz\n"; | 90 cerr << " --cutfreq [-c] freq: Set the cut off frequency of the filter in Hz\n"; |
91 cerr << " --help [-h]: Print this menu\n"; | 91 cerr << " --help [-h]: Print this menu\n"; |
92 } | 92 } |
93 | 93 |
94 int main(int argc, char *argv[]) | 94 int main(int argc, char *argv[]) |
95 { | 95 { |
96 BeagleRTInitSettings settings; // Standard audio settings | 96 BelaInitSettings settings; // Standard audio settings |
97 string fileName; // Name of the sample to load | 97 string fileName; // Name of the sample to load |
98 | 98 |
99 SampleData sampleData; // User define structure to pass data retrieved from file to render function | 99 SampleData sampleData; // User define structure to pass data retrieved from file to render function |
100 sampleData.samples = 0; | 100 sampleData.samples = 0; |
101 sampleData.sampleLen = -1; | 101 sampleData.sampleLen = -1; |
108 {"file", 1, NULL, 'f'}, | 108 {"file", 1, NULL, 'f'}, |
109 {NULL, 0, NULL, 0} | 109 {NULL, 0, NULL, 0} |
110 }; | 110 }; |
111 | 111 |
112 // Set default settings | 112 // Set default settings |
113 BeagleRT_defaultSettings(&settings); | 113 Bela_defaultSettings(&settings); |
114 | 114 |
115 // Parse command-line arguments | 115 // Parse command-line arguments |
116 while (1) { | 116 while (1) { |
117 int c; | 117 int c; |
118 if ((c = BeagleRT_getopt_long(argc, argv, "hf:c:", customOptions, &settings)) < 0) | 118 if ((c = Bela_getopt_long(argc, argv, "hf:c:", customOptions, &settings)) < 0) |
119 break; | 119 break; |
120 switch (c) { | 120 switch (c) { |
121 case 'h': | 121 case 'h': |
122 usage(basename(argv[0])); | 122 usage(basename(argv[0])); |
123 exit(0); | 123 exit(0); |
152 if(settings.verbose) | 152 if(settings.verbose) |
153 cout << "File contains " << sampleData.sampleLen << " samples" << endl; | 153 cout << "File contains " << sampleData.sampleLen << " samples" << endl; |
154 | 154 |
155 | 155 |
156 // Initialise the PRU audio device | 156 // Initialise the PRU audio device |
157 if(BeagleRT_initAudio(&settings, &sampleData) != 0) { | 157 if(Bela_initAudio(&settings, &sampleData) != 0) { |
158 cout << "Error: unable to initialise audio" << endl; | 158 cout << "Error: unable to initialise audio" << endl; |
159 return -1; | 159 return -1; |
160 } | 160 } |
161 | 161 |
162 // Start the audio device running | 162 // Start the audio device running |
163 if(BeagleRT_startAudio()) { | 163 if(Bela_startAudio()) { |
164 cout << "Error: unable to start real-time audio" << endl; | 164 cout << "Error: unable to start real-time audio" << endl; |
165 return -1; | 165 return -1; |
166 } | 166 } |
167 | 167 |
168 // Set up interrupt handler to catch Control-C and SIGTERM | 168 // Set up interrupt handler to catch Control-C and SIGTERM |
173 while(!gShouldStop) { | 173 while(!gShouldStop) { |
174 usleep(100000); | 174 usleep(100000); |
175 } | 175 } |
176 | 176 |
177 // Stop the audio device | 177 // Stop the audio device |
178 BeagleRT_stopAudio(); | 178 Bela_stopAudio(); |
179 | 179 |
180 // Clean up any resources allocated for audio | 180 // Clean up any resources allocated for audio |
181 BeagleRT_cleanupAudio(); | 181 Bela_cleanupAudio(); |
182 | 182 |
183 // All done! | 183 // All done! |
184 return 0; | 184 return 0; |
185 } | 185 } |
186 | 186 |