Jump to content

Script: Articulation zones


Unheardofski

Recommended Posts

Hi guys,

I haven't really checked if this is doable with the built in tools (I tend to use scripter for everything) but I accidentally came up with this when working on a song and messing with art in real time. Basically it is a keyboard split for different articulations depending on pitch. There is no failsafe for dummies so if you set conflicting zones you reap what you sow :)

Set the number of zones in ...wait for it.... numberOfZones. Enjoy or toss:

 

// Articulation ID Zones
// copyright codecave sthlm, 2018
// written by A. Enhardt 2018-02-03

var PluginParameters = [],
   numberOfZones = 3;

Note.prototype.determineArtID = function() {
   var noID = true;
   for (var i = 2; i <= numberOfZones + 1; i += 2) {
       if (this.pitch <= GetParameter(i)) {
           this.articulationID = GetParameter(i - 1);
           noID = false;
       }
   }
   if (noID) {
       this.articulationID = GetParameter((numberOfZones + 2));
   }
}

function numberStrings(howMany) {
   var arr = [];
   for (var i = 1; i <= howMany; i++) {
       arr.push(i.toString());
   }
   return arr;
}

PluginParameters.push({
   name: "Articulation Zones by <codecave sthlm>",
   type: "text"
})
for (var i = 1; i <= numberOfZones; i++) {
   PluginParameters.push({
       name: "Zone " + i + " articulation ID",
       type: "menu",
       valueStrings: numberStrings(16),
       minValue: 0,
       maxValue: 15,
       defaultValue: 0,
       numberOfSteps: 15
   });
   if (i !== numberOfZones) {
       PluginParameters.push({
           name: "Zone " + i + " upper bound",
           type: "menu",
           valueStrings: MIDI._noteNames.map(function(x, i) {
               return i + " / " + x
           }),
           minValue: 0,
           maxValue: 127,
           defaultValue: i * 31,
           numberOfSteps: 127
       })
   }
}

function HandleMIDI(e) {
   if (e instanceof Note) {
       e.determineArtID();
   }
   e.send();
}

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...