changeset 541:c301cc07ae11 prerelease

updated heavy to new API
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 24 Jun 2016 02:29:05 +0100
parents 67a746eea29e
children 3016638b4da2 3980b707634d
files scripts/build_pd_heavy.sh scripts/hvresources/render.cpp
diffstat 2 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/build_pd_heavy.sh	Fri Jun 24 02:12:35 2016 +0100
+++ b/scripts/build_pd_heavy.sh	Fri Jun 24 02:29:05 2016 +0100
@@ -2,6 +2,7 @@
 # This script uploads Pd patches to Enzienaudio's server and compiles them on Bela
 
 pdpath=""
+release=1
 NO_UPLOAD="0"
 WATCH="0"
 FORCE="0"
@@ -39,8 +40,8 @@
 echo "
         example: build_pd.sh -o ../projects/heavy/hello-world ../projects/heavy/pd/hello-world
       
-        -r allows to build against a specific Heavy release. Default is the 
-            most recent release ( see revision list here https://enzienaudio.com/a/releases )
+        -r allows to build against a specific Heavy release. Default is: $release (stable)
+            ( see revision list here https://enzienaudio.com/a/releases )
 "
 	build_script_usage
 }
--- 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];
 					}
 				}
 			}