map CC to sunvox module param

Pixilang programming language
Post Reply
User avatar
leondustar
Posts: 59
Joined: Tue Feb 28, 2017 12:40 am
Contact:

map CC to sunvox module param

Post by leondustar » Mon Apr 29, 2019 9:08 pm

Hi, I'm at the point that I'm receiving midi (CC) input, however I can't seem to control a metamodule-param (volume, TPL and so on).
This is the function:

Code: Select all

fn onCC( $chan, $cc, $value ){
    sprintf(midi_last, "CC%i(%i) chan(%i)", $cc, $value, $chan )
    fputs(midi_last)
    $index = modules[$chan]
    $name = dlcall(svl, sv_get_module_name, 0, $index )
    $ctlname = dlcall(svl, sv_get_module_ctl_name, 0,$index, $cc )
    sprintf(ts,"\n  => setting %s of %s to %i\n",$ctlname,$name,$value)
    fputs(ts)
    /*
       sv_send_event() - send some event (note ON, note OFF, controller change, etc.)
       Parameters:
         slot;
         track_num - track number within the pattern;
         note: 0 - nothing; 1..127 - note num; 128 - note off; 129, 130... - see NOTECMD_xxx defines;
         vel: velocity 1..129; 0 - default;
         module: 0 - nothing; 1..255 - module number + 1;
         ctl: 0xCCEE. CC - number of a controller (1..255). EE - effect;
         ctl_val: value of controller or effect.
    */
    dlcall( svl, sv_send_event, 0 /*slot*/, 0 /*tracknum*/, 0 /*note*/, 0 /*vel*/, $index+1, $cc+1, $value )
                                                                                        //    ^--- how to convert to 0xCCEE ?
}
I know I should fiddle around with some bitshift-magic here, but I was hoping to get an example :) :)

User avatar
leondustar
Posts: 59
Joined: Tue Feb 28, 2017 12:40 am
Contact:

Re: map CC to sunvox module param

Post by leondustar » Tue Apr 30, 2019 12:23 am

GOTCHA!

Code: Select all

$ctl = 0x0000
$ctl = ($cc+1) << 8
nevermind.

Post Reply