A technical support community for Apple Logic Pro users.

 
gianluca.cello
Topic Author
Posts: 2
Joined: Tue Nov 17, 2020 1:27 am

Need script to disable notes individually

Tue Nov 17, 2020 1:37 am

Hi, i need a script that makes me play only some notes on the keyboard, all the rest must be disabled or mute. Basically I would like them to play only G2, A2, B2 and C4, D4, E4.
Would that be possible or not?
Sorry but I'm not a programmer, if anyone can help me I would be very grateful.
 
User avatar
David Nahmani
Site Admin
Posts: 83570
Joined: Sat Mar 05, 2005 12:16 am
Contact:

Re: Need script to disable notes individually

Tue Nov 17, 2020 1:49 am

Yes, that's definitely possible. Easy enough that I may be able to do it, although I'm sure some people here will do a cleaner coding job of it than I can.
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
David Nahmani
Site Admin
Posts: 83570
Joined: Sat Mar 05, 2005 12:16 am
Contact:

Re: Need script to disable notes individually

Tue Nov 17, 2020 2:06 am

Here, try this:

FilterNotes.pst.zip
(430 Bytes) Downloaded 50 times
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
 
gianluca.cello
Topic Author
Posts: 2
Joined: Tue Nov 17, 2020 1:27 am

Re: Need script to disable notes individually

Tue Nov 17, 2020 2:20 am

thank you very much David, it works great!
If I want to change the active notes it would be enough for me to change the corresponding numbers in the script?
 
User avatar
David Nahmani
Site Admin
Posts: 83570
Joined: Sat Mar 05, 2005 12:16 am
Contact:

Re: Need script to disable notes individually

Tue Nov 17, 2020 2:22 am

gianluca.cello wrote:
thank you very much David, it works great!
If I want to change the active notes it would be enough for me to change the corresponding numbers in the script?

Yes exactly and if you need to include more notes just separate them with the | character. You're welcome! Glad to hear it works for you! :)
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: 3096
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Need script to disable notes individually

Tue Nov 17, 2020 3:03 am

ohh regular expressions... fancy!

If you want to use pitch names then you can use the built in function to convert it to a number automatically. Wouldn't work with David's regular expression as is though... ;-)

var pitch = MIDI.noteNumber("C3");
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
 
User avatar
David Nahmani
Site Admin
Posts: 83570
Joined: Sat Mar 05, 2005 12:16 am
Contact:

Re: Need script to disable notes individually

Tue Nov 17, 2020 3:05 am

Nice, yours makes it easier to update. BTW for anyone who wants to see just the code here it is:

function HandleMIDI(event) {
    if (event instanceof NoteOn)  {
       if (/^(55|57|59|79|81|83)$/.exec(event.pitch)) {
           event.send();
      }
   } else {
      event.send();
   }
}
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: 3096
Joined: Tue Sep 09, 2014 3:01 pm
Location: Salt Lake City, UT

Re: Need script to disable notes individually

Tue Nov 17, 2020 3:22 am

Here's one way with note names in an easy to change place

var notes = ["C3", "E3", "G3"];

function HandleMIDI(event) {
    if(event instanceof Note) {
        if( notes.includes(MIDI.noteName(event.pitch))) {
            event.send();
        }
    }
    else {
        event.send();
    }
}
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