diff 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
line wrap: on
line diff
--- a/core/RTAudio.cpp	Thu Jun 23 18:15:26 2016 +0100
+++ b/core/RTAudio.cpp	Thu Jun 23 18:17:35 2016 +0100
@@ -177,28 +177,39 @@
 
 	// 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;
+		// TODO: settings a different number of channels for inputs and outputs is not yet supported
+		gContext.analogInChannels = settings->numAnalogChannels;
+		gContext.analogOutChannels = settings->numAnalogChannels;
 		gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)settings->numAnalogChannels;
 	}
 	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 +242,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;