diff core/RTAudio.cpp @ 537:bfcbeb437869 API-update

Updated RTAudioSettings with in/out, ported some examples and libpd
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 24 Jun 2016 01:36:07 +0100
parents 5c8f46fcd4d0
children
line wrap: on
line diff
--- a/core/RTAudio.cpp	Thu Jun 23 18:17:35 2016 +0100
+++ b/core/RTAudio.cpp	Fri Jun 24 01:36:07 2016 +0100
@@ -167,11 +167,16 @@
 		}
 	}
 
+	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;
 	}
 
@@ -185,11 +190,12 @@
 	if(settings->useAnalog) {
 		gContext.audioFrames = settings->periodSize;
 
-		gContext.analogFrames = gContext.audioFrames * 4 / 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;
+		// 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;