Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
540:67a746eea29e | 541:c301cc07ae11 |
---|---|
154 unsigned int gScopeChannelsInUse; | 154 unsigned int gScopeChannelsInUse; |
155 float* gScopeOut; | 155 float* gScopeOut; |
156 | 156 |
157 | 157 |
158 bool setup(BelaContext *context, void *userData) { | 158 bool setup(BelaContext *context, void *userData) { |
159 if(context->audioInChannels != context->audioOutChannels || | |
160 context->analogInChannels != context->analogOutChannels){ | |
161 // It should actually work, but let's test it before releasing it! | |
162 printf("Error: TODO: a different number of channels for inputs and outputs is not yet supported\n"); | |
163 return false; | |
164 } | |
159 /* HEAVY */ | 165 /* HEAVY */ |
160 hvMidiHashes[kmmNoteOn] = hv_stringToHash("__hv_notein"); | 166 hvMidiHashes[kmmNoteOn] = hv_stringToHash("__hv_notein"); |
161 // hvMidiHashes[kmmNoteOff] = hv_stringToHash("noteoff"); // this is handled differently, see the render function | 167 // hvMidiHashes[kmmNoteOff] = hv_stringToHash("noteoff"); // this is handled differently, see the render function |
162 hvMidiHashes[kmmControlChange] = hv_stringToHash("__hv_ctlin"); | 168 hvMidiHashes[kmmControlChange] = hv_stringToHash("__hv_ctlin"); |
163 // Note that the ones below are not defined by Heavy, but they are here for (wishing) forward-compatibility | 169 // Note that the ones below are not defined by Heavy, but they are here for (wishing) forward-compatibility |
308 | 314 |
309 // De-interleave the data | 315 // De-interleave the data |
310 if(gHvInputBuffers != NULL) { | 316 if(gHvInputBuffers != NULL) { |
311 for(unsigned int n = 0; n < context->audioFrames; n++) { | 317 for(unsigned int n = 0; n < context->audioFrames; n++) { |
312 for(unsigned int ch = 0; ch < gHvInputChannels; ch++) { | 318 for(unsigned int ch = 0; ch < gHvInputChannels; ch++) { |
313 if(ch >= context->audioChannels+context->analogChannels) { | 319 if(ch >= context->audioInChannels+context->analogInChannels) { |
314 // THESE ARE PARAMETER INPUT 'CHANNELS' USED FOR ROUTING | 320 // THESE ARE PARAMETER INPUT 'CHANNELS' USED FOR ROUTING |
315 // 'sensor' outputs from routing channels of dac~ are passed through here | 321 // 'sensor' outputs from routing channels of dac~ are passed through here |
316 break; | 322 break; |
317 } else { | 323 } else { |
318 // If more than 2 ADC inputs are used in the pd patch, route the analog inputs | 324 // If more than 2 ADC inputs are used in the pd patch, route the analog inputs |
319 // i.e. ADC3->analogIn0 etc. (first two are always audio inputs) | 325 // i.e. ADC3->analogIn0 etc. (first two are always audio inputs) |
320 if(ch >= context->audioChannels) { | 326 if(ch >= context->audioInChannels) { |
321 int m = n/2; | 327 int m = n/2; |
322 float mIn = context->analogIn[m*context->analogChannels + (ch-context->audioChannels)]; | 328 float mIn = context->analogIn[m*context->analogInChannels + (ch-context->audioInChannels)]; |
323 gHvInputBuffers[ch * context->audioFrames + n] = mIn; | 329 gHvInputBuffers[ch * context->audioFrames + n] = mIn; |
324 } else { | 330 } else { |
325 gHvInputBuffers[ch * context->audioFrames + n] = context->audioIn[n * context->audioChannels + ch]; | 331 gHvInputBuffers[ch * context->audioFrames + n] = context->audioIn[n * context->audioInChannels + ch]; |
326 } | 332 } |
327 } | 333 } |
328 } | 334 } |
329 } | 335 } |
330 } | 336 } |
405 // Interleave the output data | 411 // Interleave the output data |
406 if(gHvOutputBuffers != NULL) { | 412 if(gHvOutputBuffers != NULL) { |
407 for(unsigned int n = 0; n < context->audioFrames; n++) { | 413 for(unsigned int n = 0; n < context->audioFrames; n++) { |
408 | 414 |
409 for(unsigned int ch = 0; ch < gHvOutputChannels; ch++) { | 415 for(unsigned int ch = 0; ch < gHvOutputChannels; ch++) { |
410 if(ch >= context->audioChannels+context->analogChannels) { | 416 if(ch >= context->audioOutChannels+context->analogOutChannels) { |
411 // THESE ARE SENSOR OUTPUT 'CHANNELS' USED FOR ROUTING | 417 // THESE ARE SENSOR OUTPUT 'CHANNELS' USED FOR ROUTING |
412 // they are the content of the 'sensor output' dac~ channels | 418 // they are the content of the 'sensor output' dac~ channels |
413 } else { | 419 } else { |
414 if(ch >= context->audioChannels) { | 420 if(ch >= context->audioOutChannels) { |
415 int m = n/2; | 421 int m = n/2; |
416 context->analogOut[m * context->analogFrames + (ch-context->audioChannels)] = constrain(gHvOutputBuffers[ch*context->audioFrames + n],0.0,1.0); | 422 context->analogOut[m * context->analogFrames + (ch-context->audioOutChannels)] = constrain(gHvOutputBuffers[ch*context->audioFrames + n],0.0,1.0); |
417 } else { | 423 } else { |
418 context->audioOut[n * context->audioChannels + ch] = gHvOutputBuffers[ch * context->audioFrames + n]; | 424 context->audioOut[n * context->audioOutChannels + ch] = gHvOutputBuffers[ch * context->audioFrames + n]; |
419 } | 425 } |
420 } | 426 } |
421 } | 427 } |
422 } | 428 } |
423 } | 429 } |