diff examples/01-Basics/passthrough/render.cpp @ 539:b486344aa796 prerelease

merge
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 24 Jun 2016 01:43:53 +0100
parents bfcbeb437869
children 8f8809c77dda
line wrap: on
line diff
--- a/examples/01-Basics/passthrough/render.cpp	Fri Jun 24 01:40:25 2016 +0100
+++ b/examples/01-Basics/passthrough/render.cpp	Fri Jun 24 01:43:53 2016 +0100
@@ -22,37 +22,43 @@
 */
 
 #include <Bela.h>
-#include <rtdk.h>
 
 bool setup(BelaContext *context, void *userData)
 {
 	// Nothing to do here...
+	if(context->audioInChannels != context->audioOutChannels ||
+			context->analogInChannels != context-> analogOutChannels){
+		printf("Error: for this project, you need the same number of input and output channels.\n");
+		return false;
+	}
 	return true;
 }
 
 void render(BelaContext *context, void *userData)
 {
+
 	// Simplest possible case: pass inputs through to outputs
 	for(unsigned int n = 0; n < context->audioFrames; n++) {
-		for(unsigned int ch = 0; ch < context->audioChannels; ch++){
+		for(unsigned int ch = 0; ch < context->audioInChannels; ch++){
 			// Two equivalent ways to write this code
 
 			// The long way, using the buffers directly:
-			// context->audioOut[n * context->audioChannels + ch] =
-			// 		context->audioIn[n * context->audioChannels + ch];
+			// context->audioOut[n * context->audioOutChannels + ch] =
+			// 		context->audioIn[n * context->audioInChannels + ch];
 
 			// Or using the macros:
 			audioWrite(context, n, ch, audioRead(context, n, ch));
 		}
 	}
 
-	// Same with analog channelss
+	// Same with analog channels
 	for(unsigned int n = 0; n < context->analogFrames; n++) {
-		for(unsigned int ch = 0; ch < context->analogChannels; ch++) {
+		for(unsigned int ch = 0; ch < context->analogInChannels; ch++) {
 			// Two equivalent ways to write this code
 
 			// The long way, using the buffers directly:
-			// context->analogOut[n * context->analogChannels + ch] = context->analogIn[n * context->analogChannels + ch];
+			// context->analogOut[n * context->analogOutChannels + ch] =
+			//  	context->analogIn[n * context->analogInChannels + ch];
 
 			// Or using the macros:
 			analogWrite(context, n, ch, analogRead(context, n, ch));