A technical support community for Apple Logic Pro users.

 
User avatar
tenorman
Topic Author
Posts: 18
Joined: Wed Feb 21, 2007 7:30 am
Location: Oshkosh, WI

Meta Events to CC or Note Velocity

Wed Apr 08, 2020 4:09 pm

Hello,

I am an arranger and realize MIDI mockups. Was wondering if anyone might write a script that converts Meta events to CC events or note velocity? I would like to be able to choose which Meta event and value to CC# and value or velocity and value. Hopefully this makes sense. Post questions.

I will compensate, no problem.

Thanks!

Tom
Mac Pro 2x 3.46 GHz 6-Core Intel Xeon
OS 10.13.6 64 GB ram
Logic Pro X 10.4.8
MOTU 828es, Focusrite Liquid 56
 
User avatar
Dewdman42
Posts: 3279
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Meta Events to CC or Note Velocity

Wed Apr 08, 2020 4:20 pm

Scripter doesn't see meta events. you will have to do that with the environment.

What meta events are you working it? In some cases you may be able to get Scripter to watch automation values and respond to those, but not actual LogicPro meta events.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
User avatar
tenorman
Topic Author
Posts: 18
Joined: Wed Feb 21, 2007 7:30 am
Location: Oshkosh, WI

Re: Meta Events to CC or Note Velocity

Thu Apr 09, 2020 11:42 am

I assume Scripter doesn't see meta events in Logic 10.4.8?? If it does see script below. If not, thank you for your help!

These are the meta events I want to work with:

Dynamic markings meta events, pppp through ffff.

Meta event# 0-ppp to CC2 value 10 or note velocity 10
Meta event# 1-pp to CC2 value 20 or note velocity 20
Meta event# 2-p to CC2 value 35 or note velocity 35
Meta event# 3-mp to CC2 value 50 or note velocity 50
Meta event# 4-mf to CC2 value 65 or note velocity 65
Meta event# 5-f to CC2 value 85 or note velocity 85
Meta event# 6-ff to CC2value 105 or note velocity 105
Meta event# 7-fff to CC2 value 115 or note velocity 115
Meta event# 12-ffff to CC2 value 127 or note velocity 127
Meta event# 13 pppp to CC2 value 5 or note velocity 5

I had this script written several years back, might this be edited for my purpose.

//
// Score to ArtID
//
// Created by Attila Enhardt on 2016-03-07
// Copyright LogicScripts 2016.
//

var PluginParameters = [];
var debug = 1;
var scriptName = 'Score to ArtID <LogicScripts> v.0.1';
//var NeedsTimingInfo = true;
//var updateGUI = 0;
var artIDs = [];
var activeArticulation = 0;
var oneShot = 0;
var shotNote = [];
var metas = [{
name : 'Select Meta + infinite/one-shot below'
}
];

function ArtID(name, number, value, oS, ix) {
this.name = name;
this.number = number;
this.value = value;
this.oS = oS;
this.ix = i;
this.set = function (args) {
if (typeof args[0] == number)
this.oneShot = args[0];
if (typeof args[1] == 'number')
this.number = args[1];
if (typeof args[2] == 'number')
this.value = args[2];
};
artIDs.push(this);
this.activate = function () {
activeArticulation = ix + 1; // double check the +1
oneShot = oS;

};

this.ppinit = (function () {
new Parameter(name + ' Ⓜ ' , 'menu', ['artNum',ix], metas.map(function (obj) {
return obj.name;
}));
new Parameter('⟾ / ① ', 'menu', ['oneShot', ix], ['Standard', 'One-Shot']);
})();


}
function Meta(name, n, v) {
this.name = v < 10 ? 'Meta n:' + n + ' v: ' + v + ' | ' + name : 'Meta n:' + n + ' v:' + v + ' | ' + name;
this.number = n;
this.value = v;
this.set = function(p) {
artIDs[p].set(['',this.number,this.value]);
};
metas.push(this);
}
function Parameter(n, t, pc, vs, miv, mav, def, nos, unit) {
if (t == 'checkbox') {
this.name = n;
this.type = t;
this.pc = pc;
this.defaultValue = 0;
PluginParameters.push(this);
} else if (t == 'div') {
this.name = '⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰';
this.type = 'text';
this.defaultValue = 0;
PluginParameters.push(this);
} else {
this.name = n;
this.type = t;
this.valueStrings = vs ? vs : 0;
this.minValue = miv ? miv : 0;
this.maxValue = mav ? mav : 0;
this.defaultValue = def ? def : 0;
this.numberOfSteps = nos ? nos : 0;
this.unit = unit;
this.pc = pc;
PluginParameters.push(this);
}
this.index = PluginParameters.length - 1;
this.remove = function () {
PluginParameters.splice(index, 1);
};
}
m601 = new Meta('Arco (text)', 60, 1);
m602 = new Meta('Pizzicato (text)', 60, 2);
m603 = new Meta('Spiccato (text)', 60, 3);
m604 = new Meta('Trill ½ step (text)', 60, 4);
m605 = new Meta('Trill 1 step (text)', 60, 5);
metas.push({
name : '▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬'
}); //U25AC
var m673 = new Meta('Staccato', 67, 3);
m675 = new Meta('Accent', 67, 5);
m677 = new Meta('Marcato', 67, 7);
m678 = new Meta('Spiccato', 67, 8);
m679 = new Meta('Legato', 67, 9);
m6712 = new Meta('Harmonics', 67, 12);
m676 = new Meta('Up bow', 67, 6);
m6711 = new Meta('Down bow', 67, 11);
m667 = new Meta('Tremolo', 66, 6);


function ppOrnament() {
new Parameter('⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰⥰', 'text');
}

function ppText(t) {
new Parameter(t, 'text');
}

function createGUI() {
ppScriptName = new ppText(scriptName);
for (i = 0; i < 16; i++) {
artIDs[i] = new ArtID('Articulation ID ' + (i + 1),0,0,0,i);
}
}

function HandleMIDI(e) {
if (e instanceof ControlChange && e.channel == 16) {
for (var i = 0; i < artIDs.length ; i++) {
if (artIDs[i].number == e.number) {
artIDs[i].activate();
return;
}
}
}
if (e instanceof Note) {
if (activeArticulation) {
e.articulationID = activeArticulation;
switch (true) {
case (e instanceof NoteOn):
shotNote.push(e);
break;
case (e instanceof NoteOff):
if (e.pitch == shotNote.pitch) {
oneShot = 0;
shotNote.splice(0, 1);
}
break;
default:
}
}
e.send();
if (debug)
e.trace();
}
}

function ParameterChanged(p, v) {
var pcNo = PluginParameters[p].pc[1],
pcName = PluginParameters[p].pc[0];
switch (pcName) {
case 'artNum':
if(v)
metas[v].set(pcNo);
break;
case 'oneShot':
if(v)
artIDs[pcNo].set(v);
break;
default:

}
}
createGUI();
Mac Pro 2x 3.46 GHz 6-Core Intel Xeon
OS 10.13.6 64 GB ram
Logic Pro X 10.4.8
MOTU 828es, Focusrite Liquid 56
 
User avatar
Dewdman42
Posts: 3279
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Meta Events to CC or Note Velocity

Thu Apr 09, 2020 11:45 am

If you markup the script code with the [code] tag it will be a lot easier to read. ;-)

Scripter does not see meta events.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
User avatar
tenorman
Topic Author
Posts: 18
Joined: Wed Feb 21, 2007 7:30 am
Location: Oshkosh, WI

Re: Meta Events to CC or Note Velocity

Thu Apr 09, 2020 11:48 am

Thank you!
Mac Pro 2x 3.46 GHz 6-Core Intel Xeon
OS 10.13.6 64 GB ram
Logic Pro X 10.4.8
MOTU 828es, Focusrite Liquid 56
 
User avatar
Dewdman42
Posts: 3279
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Meta Events to CC or Note Velocity

Thu Apr 09, 2020 11:50 am

Also you might want to consider copy and pasting your script into the following javascript beautifier...

https://beautifier.io
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram
 
User avatar
Dewdman42
Posts: 3279
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Meta Events to CC or Note Velocity

Thu Apr 09, 2020 11:58 am

So what I would recommend is that you learn more about the environment. The environment can detect and convert meta events . You might be able to use a simple environment transformer to convert meta events into some kind of CC event. Then Scripter could detect the CC event and do whatever you want to it in a more complicated manner. You could also do the whole thing entirely in the environment, but I view that as more complicated. Use environment just to transform meta events into some kind of CC event... and then in scripter you can use those CC events to do whatever you want to do to the notes entirely in the non-meta realm.
OSX 10.15 (Catalina) on OpenCore - Logic Pro 10.6.1, VePro7, Mainstage3
5,1 MacPro 3.46ghz x 12 128gb ram