diff scripts/hvresources/render.cpp @ 541:c301cc07ae11 prerelease

updated heavy to new API
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 24 Jun 2016 02:29:05 +0100
parents 85ba865d3845
children
line wrap: on
line diff
--- a/scripts/hvresources/render.cpp	Fri Jun 24 02:12:35 2016 +0100
+++ b/scripts/hvresources/render.cpp	Fri Jun 24 02:29:05 2016 +0100
@@ -156,6 +156,12 @@
 
 
 bool setup(BelaContext *context, void *userData)	{
+	if(context->audioInChannels != context->audioOutChannels ||
+			context->analogInChannels != context->analogOutChannels){
+		// It should actually work, but let's test it before releasing it!
+		printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n");
+		return false;
+	}
 	/* HEAVY */
 	hvMidiHashes[kmmNoteOn] = hv_stringToHash("__hv_notein");
 //	hvMidiHashes[kmmNoteOff] = hv_stringToHash("noteoff"); // this is handled differently, see the render function
@@ -310,19 +316,19 @@
 	if(gHvInputBuffers != NULL) {
 		for(unsigned int n = 0; n < context->audioFrames; n++) {
 			for(unsigned int ch = 0; ch < gHvInputChannels; ch++) {
-				if(ch >= context->audioChannels+context->analogChannels) {
+				if(ch >= context->audioInChannels+context->analogInChannels) {
 					// THESE ARE PARAMETER INPUT 'CHANNELS' USED FOR ROUTING
 					// 'sensor' outputs from routing channels of dac~ are passed through here
 					break;
 				} else {
 					// If more than 2 ADC inputs are used in the pd patch, route the analog inputs
 					// i.e. ADC3->analogIn0 etc. (first two are always audio inputs)
-					if(ch >= context->audioChannels)	{
+					if(ch >= context->audioInChannels)	{
 						int m = n/2;
-						float mIn = context->analogIn[m*context->analogChannels + (ch-context->audioChannels)];
+						float mIn = context->analogIn[m*context->analogInChannels + (ch-context->audioInChannels)];
 						gHvInputBuffers[ch * context->audioFrames + n] = mIn;
 					} else {
-						gHvInputBuffers[ch * context->audioFrames + n] = context->audioIn[n * context->audioChannels + ch];
+						gHvInputBuffers[ch * context->audioFrames + n] = context->audioIn[n * context->audioInChannels + ch];
 					}
 				}
 			}
@@ -407,15 +413,15 @@
 		for(unsigned int n = 0; n < context->audioFrames; n++) {
 
 			for(unsigned int ch = 0; ch < gHvOutputChannels; ch++) {
-				if(ch >= context->audioChannels+context->analogChannels) {
+				if(ch >= context->audioOutChannels+context->analogOutChannels) {
 					// THESE ARE SENSOR OUTPUT 'CHANNELS' USED FOR ROUTING
 					// they are the content of the 'sensor output' dac~ channels
 				} else {
-					if(ch >= context->audioChannels)	{
+					if(ch >= context->audioOutChannels)	{
 						int m = n/2;
-						context->analogOut[m * context->analogFrames + (ch-context->audioChannels)] = constrain(gHvOutputBuffers[ch*context->audioFrames + n],0.0,1.0);
+						context->analogOut[m * context->analogFrames + (ch-context->audioOutChannels)] = constrain(gHvOutputBuffers[ch*context->audioFrames + n],0.0,1.0);
 					} else {
-						context->audioOut[n * context->audioChannels + ch] = gHvOutputBuffers[ch * context->audioFrames + n];
+						context->audioOut[n * context->audioOutChannels + ch] = gHvOutputBuffers[ch * context->audioFrames + n];
 					}
 				}
 			}