Mercurial > hg > beaglert
comparison examples/basic_FFT_phase_vocoder/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 |
---|---|
13 #include <getopt.h> | 13 #include <getopt.h> |
14 #include <unistd.h> | 14 #include <unistd.h> |
15 #include <sys/time.h> | 15 #include <sys/time.h> |
16 #include <sndfile.h> // to load audio files | 16 #include <sndfile.h> // to load audio files |
17 #include "SampleData.h" | 17 #include "SampleData.h" |
18 #include <BeagleRT.h> | 18 #include <Bela.h> |
19 | 19 |
20 using namespace std; | 20 using namespace std; |
21 | 21 |
22 // Global variables used by getCurrentTime() | 22 // Global variables used by getCurrentTime() |
23 unsigned long long gFirstSeconds, gFirstMicroseconds; | 23 unsigned long long gFirstSeconds, gFirstMicroseconds; |
84 // Print usage information | 84 // Print usage information |
85 void usage(const char * processName) | 85 void usage(const char * processName) |
86 { | 86 { |
87 cerr << "Usage: " << processName << " [options]" << endl; | 87 cerr << "Usage: " << processName << " [options]" << endl; |
88 | 88 |
89 BeagleRT_usage(); | 89 Bela_usage(); |
90 | 90 |
91 cerr << " --help [-h]: Print this menu\n"; | 91 cerr << " --help [-h]: Print this menu\n"; |
92 } | 92 } |
93 | 93 |
94 /* Function which returns the time since start of the program | 94 /* Function which returns the time since start of the program |
103 return (double)result / 1000000.0; | 103 return (double)result / 1000000.0; |
104 } | 104 } |
105 extern SampleData gSampleData; | 105 extern SampleData gSampleData; |
106 int main(int argc, char *argv[]) | 106 int main(int argc, char *argv[]) |
107 { | 107 { |
108 BeagleRTInitSettings settings; // Standard audio settings | 108 BelaInitSettings settings; // Standard audio settings |
109 struct timeval tv; | 109 struct timeval tv; |
110 string fileName; // Name of the sample to load | 110 string fileName; // Name of the sample to load |
111 | 111 |
112 struct option customOptions[] = | 112 struct option customOptions[] = |
113 { | 113 { |
118 | 118 |
119 gSampleData.samples = 0; | 119 gSampleData.samples = 0; |
120 gSampleData.sampleLen = -1; | 120 gSampleData.sampleLen = -1; |
121 | 121 |
122 // Set default settings | 122 // Set default settings |
123 BeagleRT_defaultSettings(&settings); | 123 Bela_defaultSettings(&settings); |
124 | 124 |
125 settings.periodSize = 32; // Larger period size by default, for testing | 125 settings.periodSize = 32; // Larger period size by default, for testing |
126 | 126 |
127 // Parse command-line arguments | 127 // Parse command-line arguments |
128 while (1) { | 128 while (1) { |
129 int c; | 129 int c; |
130 if ((c = BeagleRT_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) | 130 if ((c = Bela_getopt_long(argc, argv, "hf:", customOptions, &settings)) < 0) |
131 break; | 131 break; |
132 switch (c) { | 132 switch (c) { |
133 case 'h': | 133 case 'h': |
134 usage(basename(argv[0])); | 134 usage(basename(argv[0])); |
135 exit(0); | 135 exit(0); |
158 if(settings.verbose) | 158 if(settings.verbose) |
159 cout << "File contains " << gSampleData.sampleLen << " samples" << endl; | 159 cout << "File contains " << gSampleData.sampleLen << " samples" << endl; |
160 | 160 |
161 | 161 |
162 // Initialise the PRU audio device | 162 // Initialise the PRU audio device |
163 if(BeagleRT_initAudio(&settings, &gSampleData) != 0) { | 163 if(Bela_initAudio(&settings, &gSampleData) != 0) { |
164 cout << "Error: unable to initialise audio" << endl; | 164 cout << "Error: unable to initialise audio" << endl; |
165 return -1; | 165 return -1; |
166 } | 166 } |
167 | 167 |
168 // Initialise time | 168 // Initialise time |
169 gettimeofday(&tv, NULL); | 169 gettimeofday(&tv, NULL); |
170 gFirstSeconds = tv.tv_sec; | 170 gFirstSeconds = tv.tv_sec; |
171 gFirstMicroseconds = tv.tv_usec; | 171 gFirstMicroseconds = tv.tv_usec; |
172 | 172 |
173 // Start the audio device running | 173 // Start the audio device running |
174 if(BeagleRT_startAudio()) { | 174 if(Bela_startAudio()) { |
175 cout << "Error: unable to start real-time audio" << endl; | 175 cout << "Error: unable to start real-time audio" << endl; |
176 return -1; | 176 return -1; |
177 } | 177 } |
178 | 178 |
179 // Set up interrupt handler to catch Control-C | 179 // Set up interrupt handler to catch Control-C |
184 while(!gShouldStop) { | 184 while(!gShouldStop) { |
185 usleep(100000); | 185 usleep(100000); |
186 } | 186 } |
187 | 187 |
188 // Stop the audio device | 188 // Stop the audio device |
189 BeagleRT_stopAudio(); | 189 Bela_stopAudio(); |
190 | 190 |
191 // Clean up any resources allocated for audio | 191 // Clean up any resources allocated for audio |
192 BeagleRT_cleanupAudio(); | 192 Bela_cleanupAudio(); |
193 | 193 |
194 // All done! | 194 // All done! |
195 return 0; | 195 return 0; |
196 } | 196 } |