diff examples/04-Audio/filter-IIR/render.cpp @ 544:cdabbaf3a252 prerelease

Updated Audio examples for audioOutChannels etc.
author Robert Jack <robert.h.jack@gmail.com>
date Fri, 24 Jun 2016 13:32:07 +0100
parents 1cec96845a23
children
line wrap: on
line diff
--- a/examples/04-Audio/filter-IIR/render.cpp	Fri Jun 24 13:19:52 2016 +0100
+++ b/examples/04-Audio/filter-IIR/render.cpp	Fri Jun 24 13:32:07 2016 +0100
@@ -63,6 +63,13 @@
 bool setup(BelaContext *context, void *userData)
 {
 
+	// Check that we have the same number of inputs and outputs.
+	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;
+	}
+
 	// Retrieve a parameter passed in from the initAudio() call
 	gSampleData = *(SampleData *)userData;
 
@@ -97,8 +104,8 @@
 		gLastY[1] = gLastY[0];
 		gLastY[0] = out;
 
-		for(unsigned int channel = 0; channel < context->audioChannels; channel++)
-			context->audioOut[n * context->audioChannels + channel] = out;	// ...and put it in both left and right channel
+		for(unsigned int channel = 0; channel < context->audioOutChannels; channel++)
+			context->audioOut[n * context->audioOutChannels + channel] = out;	// ...and put it in both left and right channel
 
 	}