Mercurial > hg > beaglert
comparison core/RTAudio.cpp @ 528:5c8f46fcd4d0 API-update
Updated BelaContext to use separate values for in/ou channels
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 23 Jun 2016 18:17:35 +0100 |
parents | a0698d523a6a |
children | bfcbeb437869 |
comparison
equal
deleted
inserted
replaced
527:1c68ad13bbe4 | 528:5c8f46fcd4d0 |
---|---|
175 return -1; | 175 return -1; |
176 } | 176 } |
177 | 177 |
178 // Initialise the rendering environment: sample rates, frame counts, numbers of channels | 178 // Initialise the rendering environment: sample rates, frame counts, numbers of channels |
179 gContext.audioSampleRate = 44100.0; | 179 gContext.audioSampleRate = 44100.0; |
180 gContext.audioChannels = 2; | 180 |
181 // TODO: settings a different number of channels for inputs and outputs is not yet supported | |
182 gContext.audioInChannels = 2; | |
183 gContext.audioOutChannels = 2; | |
181 | 184 |
182 if(settings->useAnalog) { | 185 if(settings->useAnalog) { |
183 gContext.audioFrames = settings->periodSize; | 186 gContext.audioFrames = settings->periodSize; |
184 | 187 |
185 gContext.analogFrames = gContext.audioFrames * 4 / settings->numAnalogChannels; | 188 gContext.analogFrames = gContext.audioFrames * 4 / settings->numAnalogChannels; |
186 gContext.analogChannels = settings->numAnalogChannels; | 189 // TODO: settings a different number of channels for inputs and outputs is not yet supported |
190 gContext.analogInChannels = settings->numAnalogChannels; | |
191 gContext.analogOutChannels = settings->numAnalogChannels; | |
187 gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)settings->numAnalogChannels; | 192 gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)settings->numAnalogChannels; |
188 } | 193 } |
189 else { | 194 else { |
190 gContext.audioFrames = settings->periodSize; | 195 gContext.audioFrames = settings->periodSize; |
191 | 196 |
192 gContext.analogFrames = 0; | 197 gContext.analogFrames = 0; |
193 gContext.analogChannels = 0; | 198 gContext.analogInChannels = 0; |
199 gContext.analogOutChannels = 0; | |
194 gContext.analogSampleRate = 0; | 200 gContext.analogSampleRate = 0; |
195 } | 201 } |
196 | 202 |
203 if(gContext.analogInChannels != gContext.analogOutChannels){ | |
204 printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); | |
205 return -1; | |
206 } | |
207 unsigned int analogChannels = gContext.analogInChannels; | |
197 // Sanity check the combination of channels and period size | 208 // Sanity check the combination of channels and period size |
198 if( gContext.analogChannels != 0 && ((gContext.analogChannels <= 4 && gContext.analogFrames < 2) || | 209 if( analogChannels != 0 && ((analogChannels <= 4 && gContext.analogFrames < 2) || |
199 (gContext.analogChannels <= 2 && gContext.analogFrames < 4)) ) | 210 (analogChannels <= 2 && gContext.analogFrames < 4)) ) |
200 { | 211 { |
201 cout << "Error: " << gContext.analogChannels << " channels and period size of " << gContext.analogFrames << " not supported.\n"; | 212 cout << "Error: " << analogChannels << " channels and period size of " << gContext.analogFrames << " not supported.\n"; |
202 return 1; | 213 return 1; |
203 } | 214 } |
204 | 215 |
205 // For now, digital frame rate is equal to audio frame rate | 216 // For now, digital frame rate is equal to audio frame rate |
206 if(settings->useDigital) { | 217 if(settings->useDigital) { |
229 cout << "Error: unable to prepare GPIO for PRU audio\n"; | 240 cout << "Error: unable to prepare GPIO for PRU audio\n"; |
230 return 1; | 241 return 1; |
231 } | 242 } |
232 | 243 |
233 // Get the PRU memory buffers ready to go | 244 // Get the PRU memory buffers ready to go |
234 if(gPRU->initialise(settings->pruNumber, gContext.analogFrames, gContext.analogChannels, | 245 if(gContext.analogInChannels != gContext.analogOutChannels){ |
246 printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); | |
247 return 1; | |
248 } | |
249 | |
250 if(gPRU->initialise(settings->pruNumber, gContext.analogFrames, analogChannels, | |
235 settings->numMuxChannels, true)) { | 251 settings->numMuxChannels, true)) { |
236 cout << "Error: unable to initialise PRU\n"; | 252 cout << "Error: unable to initialise PRU\n"; |
237 return 1; | 253 return 1; |
238 } | 254 } |
239 | 255 |