Jump to content

Help with assigning CC created in scripter


t-ride

Recommended Posts

Hi there everybody,

 

I am trying to map velocity to MIDI CC but without any good results so far. I have programmed a script which performs the task, namely it takes incoming note velocity and creates new MIDI CC output based on the velocity. Now my problem is that even though I output MIDI CC with the scripter plugin, these newly created CC values does not have any effect when I assign something to the controller. In my test case I am creating new Ctrl#20 and Ctrl#21 values based on the velocity and when I setup my synths in logic to be controlled by these it does not have any effect. I want to ask you guys here if you know what the problem could be. I have attached the script below.

When I log values in the scripter it seems that my output values are correct but I don't seem to be able to assign the controller values to anything...

 

(I know that it can seem a bit strange to map velocity to create new cc values but it makes sense in my application....)

 

Thanks,

// Hjalmar

 

/*****************************************************
* plugin  variables & prep
*****************************************************/
var prevVelocity = null, prevIndex = null, steps = 16, that=this;

var numMap = {  "0":0.03,   "1":0.06,   "2":0.09,   "3":0.12,   "4":0.15,   "5":0.18,  "6":0.21,    "7":0.25,
               "8":0.28,   "9":0.31,  "10":0.34,  "11":0.37,  "12":0.40,  "13":0.43,  "14":0.46,  "15":0.50,
               "16":0.53,  "17":0.56,   "18":0.59,  "19":0.62,  "20":0.65,  "21":0.68,  "22":0.71,  "23":0.75,
               "24":0.78,  "25":0.81,  "26":0.84,  "27":0.87, "28":0.90,   "29":0.93,  "30":0.96,  "31":1.00,};

var denMap = { "0": 0.11, "1": 0.25, "2": 0.37, "3": 0.50, "4": 0.62, "5": 0.75, "6": 0.87, "7": 1.00};

/*****************************************************
* plugin  menu
*****************************************************/
var PluginParameters = [
   {   name: "num1", type:"menu", defaultValue: 0, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num2", type:"menu", defaultValue: 2, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num3", type:"menu", defaultValue: 3, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num4", type:"menu", defaultValue: 4, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num5", type:"menu", defaultValue: 5, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num6", type:"menu", defaultValue: 6, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num7", type:"menu", defaultValue: 7, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num8", type:"menu", defaultValue: 8, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num9", type:"menu", defaultValue: 9, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num10", type:"menu", defaultValue: 0, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num11", type:"menu", defaultValue: 1, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num12", type:"menu", defaultValue: 2, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num13", type:"menu", defaultValue: 3, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num14", type:"menu", defaultValue: 4, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num15", type:"menu", defaultValue: 5, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "num16", type:"menu", defaultValue: 6, valueStrings:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"], },
   {   name: "den1", type: "menu", defaultValue: 7, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den2", type: "menu", defaultValue: 8, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den3", type: "menu", defaultValue: 9, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den4", type: "menu", defaultValue: 0, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den5", type: "menu", defaultValue: 1, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den6", type: "menu", defaultValue: 2, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den7", type: "menu", defaultValue: 3, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den8", type: "menu", defaultValue: 4, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den9", type: "menu", defaultValue: 5, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den10", type: "menu", defaultValue: 6, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den11", type: "menu", defaultValue: 7, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den12", type: "menu", defaultValue: 8, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den13", type: "menu", defaultValue: 9, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den14", type: "menu", defaultValue: 0, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den15", type: "menu", defaultValue: 1, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   {   name: "den16", type: "menu", defaultValue: 2, valueStrings:["1", "2", "4", "8","12","16","24","32"], }, 
   ];

/*****************************************************
* plugin code below
*****************************************************/
function HandleMIDI(e) {
       if (e instanceof NoteOn) {
   vel = e.velocity;

   //if (vel == that.prevVelocity) { e.send(); return } that.prevVelocity = vel;
   
   var ccNum = new ControlChange, ccDen = new ControlChange; ccNum.number = 20; ccDen.number = 21;

       
   for (var i = 1; i <= that.steps; i++) {
       
       //  if (i == that.prevIndex) { continue; }
       
       if ( vel <  8*i ) {

           ccNum.value = that.numMap[GetParameter("num"+i)]; ccDen.value = that.denMap[GetParameter("den"+i)];

           ccNum.send(); ccDen.send();
                    Trace(GetParameter("num"+i));
               
           e.send();

           that.prevIndex = i;
           return
       }
   }
   } else {
           e.send();
   }
}







Link to comment
Share on other sites

Okay so I've solved this problem, but I don't know how to delete the thread :P

Don't!

:idea:

Why not share your experience and your solution?

 

You're right! So the problem was that my output values for the CC was in decimal form, whilst the CC values in the automation/midi-draw lane are from 0 - 100, and so the only thing I needed to do was to scale the values by a 100. The purpose of the patch is to be able to change lfo-sync values based on the velocity of midi events. this is because in leading synths in trap, dubstep, and what not are usually not varying so much in dynamics, and therefore it makes sense to use the velocity for triggering different lfo values. because in this way I can control the lfo at the same time as I am programming the midi notes. And so in the end this patch makes it possible to use, different pitches with different rhythmical values. However, this patch is intended to be used with a synth such as NI Massive, because the lfo-sync is determined both by setting the numerator and denumerator. i glad because this patch works amazingly well and it accomplishes something that is really annoying to do with other types of routings or implementations. however, the patch has to be optimized and rewritten some more. :)

It's too bad though that you can't embedd more information into midi events because if that was possible then it would be possible to make so much more responsive and cool midi programming. It would be nice if you could add some kind of meta data to each note. I don't know if this is possible as of now.

Link to comment
Share on other sites

Thanx for sharing your experience!

Have you considered experimenting with the Modifier MIDI plugin? Either as single or multiple instances of same?

Speaking of note event meta data, have you explored articulation ID?

 

dude, thanks for pointing me towards articulation ID. I think that is probably the best way of controlling different types of articulations of synths. Thanks a lot!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...