J. King Posted Sunday at 11:06 PM Share Posted Sunday at 11:06 PM Hello everyone! Wondering if someone can help me out with a CAL script to select every second note in the piano roll when working with MIDI. When editing drums, kick lets say, it would be awesome if every second midi note could be selected so I could easily drop them in a new spot to trigger a different sample (same kick tuned slightly different for realism). I've been doing this manually forever, has to be a workaround in this day and age hahaha. Grok spit this code out but I was getting a CAL error 5 Unknown variable Note.Selected (do (int noteCount 0) (forEachEvent (if (== Event.Kind NOTE) (do (++ noteCount) (if (== (% noteCount 2) 1) (= Note.Selected 1) (= Note.Selected 0) ) ) ) ) ) Searched forums, found the "Are CAL scripts doomed?" Please do not rid of these gang, infinite time savers! Any help would be appreciated if someone can get this working 🍻 (Just realized this becomes faster doing this in the event list but still a Run CAL could make it quicker!) Link to comment Share on other sites More sharing options...
msmcleod Posted Sunday at 11:20 PM Share Posted Sunday at 11:20 PM Two things: 1. There's no such thing as Note - you probably meant Event 2. Neither Note.Selected or Event.Selected is a thing. You can't actually select individual events using CAL, as the selection is the thing forEachEvent is iterating over. You can select whole tracks using CAL using TrackSelect, but not individual events. Link to comment Share on other sites More sharing options...
J. King Posted Monday at 12:04 AM Author Share Posted Monday at 12:04 AM Thanks for the reply. Yes, event is the proper term. So the long and short is you have to do this manually... It did dawn on me that this is a lot faster in the "Event List" view so I'll take the win there. I could also tweak filters in the Drum Replacer - Copy MIDI events and when pasting it'll give me 3 different MIDI events. Appreciate the help Link to comment Share on other sites More sharing options...
Promidi Posted Monday at 08:06 AM Share Posted Monday at 08:06 AM Try this CAL script. (one I wrote for this very purpose) It prompt you for nth note to select, defaults to 2 (do (int note_number 1) (int even 0) (int nth 2) (getInt nth "Please enter nth note" 2 50) (forEachEvent (if (== Event.Kind NOTE) (do (= even (% note_number nth)) (if (== even 1) (do );exit do (do (delete) (insert Event.Time Event.Chan NOTE Note.Key Note.Vel Note.Dur) ) );exit if (++ note_number) );exit do );exit if );exit for );exit do 1 2 1 Link to comment Share on other sites More sharing options...
msmcleod Posted Monday at 08:28 AM Share Posted Monday at 08:28 AM 20 minutes ago, Promidi said: Try this CAL script. (one I wrote for this very purpose) It prompt you for nth note to select, defaults to 2 (do (int note_number 1) (int even 0) (int nth 2) (getInt nth "Please enter nth note" 2 50) (forEachEvent (if (== Event.Kind NOTE) (do (= even (% note_number nth)) (if (== even 1) (do );exit do (do (delete) (insert Event.Time Event.Chan NOTE Note.Key Note.Vel Note.Dur) ) );exit if (++ note_number) );exit do );exit if );exit for );exit do Aha - a clever solution... delete the note then add it again so the new one isn't selected. Link to comment Share on other sites More sharing options...
J. King Posted 23 hours ago Author Share Posted 23 hours ago OMG! You're the greatest! Eazy peazy. Even the default gets the results but love the fact you can play with it. Been doing this by hand for far too long LOL Appreciate that 🍻 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now