Mercurial > hg > beaglert
diff core/RTAudio.cpp @ 539:b486344aa796 prerelease
merge
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 24 Jun 2016 01:43:53 +0100 |
parents | bfcbeb437869 |
children |
line wrap: on
line diff
--- a/core/RTAudio.cpp Fri Jun 24 01:40:25 2016 +0100 +++ b/core/RTAudio.cpp Fri Jun 24 01:43:53 2016 +0100 @@ -167,38 +167,55 @@ } } + if(settings->numAnalogInChannels != settings->numAnalogOutChannels){ + printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); + return 1; + } + unsigned int numAnalogChannels = settings->numAnalogInChannels; // Limit the analog channels to sane values - if(settings->numAnalogChannels != 2 - && settings->numAnalogChannels != 4 - && settings->numAnalogChannels != 8) { - cout << "Invalid number of analog channels: " << settings->numAnalogChannels << ". Valid values are 2, 4, 8.\n"; + if(numAnalogChannels != 2 + && numAnalogChannels != 4 + && numAnalogChannels != 8) { + cout << "Invalid number of analog channels: " << numAnalogChannels << ". Valid values are 2, 4, 8.\n"; return -1; } // Initialise the rendering environment: sample rates, frame counts, numbers of channels gContext.audioSampleRate = 44100.0; - gContext.audioChannels = 2; + + // TODO: settings a different number of channels for inputs and outputs is not yet supported + gContext.audioInChannels = 2; + gContext.audioOutChannels = 2; if(settings->useAnalog) { gContext.audioFrames = settings->periodSize; - gContext.analogFrames = gContext.audioFrames * 4 / settings->numAnalogChannels; - gContext.analogChannels = settings->numAnalogChannels; - gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)settings->numAnalogChannels; + // TODO: a different number of channels for inputs and outputs is not yet supported + gContext.analogFrames = gContext.audioFrames * 4 / settings->numAnalogInChannels; + gContext.analogInChannels = settings->numAnalogInChannels; + gContext.analogOutChannels = settings->numAnalogOutChannels; + unsigned int numAnalogChannelsForSampleRate = settings->numAnalogInChannels; + gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)numAnalogChannelsForSampleRate; } else { gContext.audioFrames = settings->periodSize; gContext.analogFrames = 0; - gContext.analogChannels = 0; + gContext.analogInChannels = 0; + gContext.analogOutChannels = 0; gContext.analogSampleRate = 0; } + if(gContext.analogInChannels != gContext.analogOutChannels){ + printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); + return -1; + } + unsigned int analogChannels = gContext.analogInChannels; // Sanity check the combination of channels and period size - if( gContext.analogChannels != 0 && ((gContext.analogChannels <= 4 && gContext.analogFrames < 2) || - (gContext.analogChannels <= 2 && gContext.analogFrames < 4)) ) + if( analogChannels != 0 && ((analogChannels <= 4 && gContext.analogFrames < 2) || + (analogChannels <= 2 && gContext.analogFrames < 4)) ) { - cout << "Error: " << gContext.analogChannels << " channels and period size of " << gContext.analogFrames << " not supported.\n"; + cout << "Error: " << analogChannels << " channels and period size of " << gContext.analogFrames << " not supported.\n"; return 1; } @@ -231,7 +248,12 @@ } // Get the PRU memory buffers ready to go - if(gPRU->initialise(settings->pruNumber, gContext.analogFrames, gContext.analogChannels, + if(gContext.analogInChannels != gContext.analogOutChannels){ + printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); + return 1; + } + + if(gPRU->initialise(settings->pruNumber, gContext.analogFrames, analogChannels, settings->numMuxChannels, true)) { cout << "Error: unable to initialise PRU\n"; return 1;