Skip to content

Instantly share code, notes, and snippets.

@bayareawebpro
Created April 25, 2021 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayareawebpro/7990d5c096de806268bd2f00d06fca36 to your computer and use it in GitHub Desktop.
Save bayareawebpro/7990d5c096de806268bd2f00d06fca36 to your computer and use it in GitHub Desktop.
/**
* Plugin Menu & Defaults
*/
var PluginParameters = [
{
type:"menu",
name:"Channel",
defaultValue:1,
numberOfSteps:16,
valueStrings: [
"Channel 1",
"Channel 2",
"Channel 3",
"Channel 4",
"Channel 5",
"Channel 6",
"Channel 7",
"Channel 8",
"Channel 9",
"Channel 10",
"Channel 11",
"Channel 12",
"Channel 13",
"Channel 14",
"Channel 15",
"Channel 16"
]
},
{
name:"Zone 1",
defaultValue:60,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 2",
defaultValue:61,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 3",
defaultValue:62,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 4",
defaultValue:63,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 5",
defaultValue:64,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 6",
defaultValue:65,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
{
name:"Zone 7",
defaultValue:66,
minValue:1,
maxValue:127,
numberOfSteps:126,
type:"lin"
},
];
/**
* Handle Midi Event
* @param event
* @constructor
*/
function HandleMIDI(event) {
if (event instanceof Note && event.channel === (1 + GetParameter('Channel'))) {
var config = PluginParameters.find(function(config){
return config.defaultValue == event.pitch
})
if(config){
var pitch = event.pitch
event.pitch = GetParameter(config.name)
Trace(`Channel ${event.channel}: ${pitch} => ${event.pitch}`)
}
}
event.send();
}
@bayareawebpro
Copy link
Author

bayareawebpro commented Jun 23, 2021

The configuration array at the top will create a set of sliders, one for each specific midi drum pad zone (1-7). Our zone sliders will shift the incoming notes for each zone.

The default value of each zone is the incoming note value we need to look for.
The selected value is the pitch will we map the note to.

The Handle Midi function will test to see if the incoming note matches our selected channel. The array of channels starts with an index of Zero, so we must add one (+ 1) to shift that value to the proper starting index of midi channels (1-16).

Then we can find the setting for the zone, based on the default note value contained in the configuration array.
We then set the incoming note with the target pitch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment