A technical support community for Apple Logic Pro users.

 
AlexBerty
Topic Author
Posts: 11
Joined: Thu Jul 16, 2020 4:35 pm

Script needed: change note number after CC values

Thu Jul 16, 2020 5:16 pm

Hello, I'm new to Logic and I need a Midi Plugin. Unfortunately I don't have any Scripter skills...

So my hope is that an expert here can help me out.

I need the following (for drum sampler hihat):

the two incoming midi notes 26 and 46 shall alter after CC4 values.

Example:
incoming CC4 value range 127 - 111 --> note 26 stays note 26 + note 46 stays note 46
incoming CC4 value range 110 - 91 --> note 26 becomes note 25 + note 46 becomes note 70
incoming CC4 value range 90 - 81 --> note 26 becomes note 24 + note 46 becomes note 71
incoming CC4 value range 80 - 71 --> note 26 becomes note 23 + note 46 becomes note 72
incoming CC4 value range 70 - 61 --> note 26 becomes note 22 + note 46 becomes note 73
incoming CC4 value range 60 - 41 --> note 26 becomes note 21 + note 46 becomes note 74
incoming CC4 value range 40 - 0 --> note 26 becomes note 20 + note 46 becomes note 75

All other note numbers that are not involved here (0 - 19 ; 27 - 45 ; 47 - 69 ; 76 - 127) shall get through without any changes and also other CC numbers (and their values) + polyphonic aftertouch.
And it is important that it works without adding latency (it is meant for real time drumming).

Is it possible for an expert to write such a script for me? If it works properly I will donate. Thanks in advance! AlexBerty :)
 
User avatar
David Nahmani
Site Admin
Posts: 83510
Joined: Sat Mar 05, 2005 12:16 am
Contact:

Re: Script needed: change note number after CC values

Sun Jul 19, 2020 11:02 pm

I suppose you may be able to hack it even if you're not a programmer. I'm no scripting expert so hopefully some more helpful Logic user can chime in here. Meanwhile see if those threads can help you get started?

viewtopic.php?t=115292
viewtopic.php?t=126947
viewtopic.php?t=128868
David Nahmani
• My Logic Pro X 10.5 book (Apple Pro Training Series)
Contact me for Private Lessons
Logic Pro X 10.6.1
MacBook Air 1.3 GHz i5 — MacOS X 11.0.1 — 4 GB RAM
iMac 3.2 GHz Quad Core i5 — MacOS X 10.15.4 — 8 GB RAM
 
User avatar
Dewdman42
Posts: 3093
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Script needed: change note number after CC values

Mon Jul 20, 2020 2:03 pm

Try this:

// pitch remap array
var remap = [];

// initialize the values
for(let i=0;i<=127;i++) {
    remap[i]=i;
}

// noteOn queue
var sustainingA = [];
var sustainingB = [];

function HandleMIDI(event) {

    if(event instanceof ControlChange && event.number == 4) {
   
        if(event.value <= 127 && event.value >= 111) {
            remap[26]=26;
            remap[46]=46;
        }
        else if(event.value <= 110 && event.value >= 91) {
            remap[26]=25;
            remap[46]=70;
        }
        else if(event.value <= 90 && event.value >= 81) {
            remap[26]=24;
            remap[46]=71;
        }
        else if(event.value <= 80 && event.value >= 71) {
            remap[26]=23;
            remap[46]=72;
        }
        else if(event.value <= 70 && event.value >= 61) {
            remap[26]=22;
            remap[46]=73;
        }
        else if(event.value <= 60 && event.value >= 41) {
            remap[26]=21;
            remap[46]=74;
        }
        else if(event.value <= 40) {
            remap[26]=20;
            remap[46]=75;
        }
       
        // event.send();  // send CC4 through?
        return;   
    }
   
    // NoteOn
    if(event instanceof NoteOn) {
       
        if(event.pitch == 26) {
           event.pitch = remap[event.pitch];
           sustainingA.push(event.pitch);
        }
        else if(event.pitch == 46) {
           event.pitch = remap[event.pitch];
           sustainingB.push(event.pitch);
        }
       
        event.send();
        return;
    }
   
    // NoteOff
    if(event instanceof NoteOff) {
   
        if(event.pitch == 26) {
            event.pitch = sustainingA.shift();
        }
        else if(event.pitch == 46) {
            event.pitch = sustainingB.shift();
        }
       
        event.send();
        return;
    }
       
    // All other events
    event.send();   
}
Last edited by Dewdman42 on Mon Jul 20, 2020 2:14 pm, edited 2 times in total.
5,1 MacPro 3.46ghz x 12 128gb ram, OSX 10.15 on OpenCore, Logic Pro 10.5, Mainstage3, Cubase10.5, StudioOne4, Reaper, DP10, VEP7, VSL, too many plugins to list
 
AlexBerty
Topic Author
Posts: 11
Joined: Thu Jul 16, 2020 4:35 pm

Re: Script needed: change note number after CC values

Mon Jul 20, 2020 2:10 pm

Thanks man, I try to get in contact with the users answering on those threads.

I think I'm looking for a pro (as there are many other midi bending requests...). Is here any pro who can provide commissioned work?
 
User avatar
Dewdman42
Posts: 3093
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Script needed: change note number after CC values

Mon Jul 20, 2020 2:12 pm

Unfortunately I do not have time to do that sort of thing..... But perhaps you can use the above example to figure things out... I updated the script just now, found some errors. FYI.
5,1 MacPro 3.46ghz x 12 128gb ram, OSX 10.15 on OpenCore, Logic Pro 10.5, Mainstage3, Cubase10.5, StudioOne4, Reaper, DP10, VEP7, VSL, too many plugins to list
 
AlexBerty
Topic Author
Posts: 11
Joined: Thu Jul 16, 2020 4:35 pm

Re: Script needed: change note number after CC values

Mon Jul 20, 2020 2:16 pm

Dewdman42 wrote:
Try this:
...


Hey Dewdman42, thanks soooo much! I'll try tomorrow and report back. :D
 
AlexBerty
Topic Author
Posts: 11
Joined: Thu Jul 16, 2020 4:35 pm

Re: Script needed: change note number after CC values

Wed Jul 22, 2020 5:51 am

Works so great!!! Thanks Dewdman42!!!!! :)