Override sustain pedal on a per-pitch basis with velocity = 1 note events

Options
realdealpeel
realdealpeel Member Posts: 20 Member

I have this very simple script working fine below but it's only able to send note-offs for all note events. I want to be able to only send note-offs to note events of the same pitch as the note event with velocity = 1, the instant that note is played.

on init

declare polyphonic $v
declare polyphonic $notenumber

end on

on note

$v := get_event_par($EVENT_ID,$EVENT_PAR_VELOCITY)
$notenumber := get_event_par($EVENT_ID,$EVENT_NOTE)

if($v = 1)
   note_off($ALL_EVENTS)   

end if

end on 

The $notenumber part of the script isn't doing anything but I want it to. Somehow I need to filter $ALL_EVENTS to only include note events of the same pitch as the velocity = 1 note.

Seems like it should be really simple and I'm just missing something basic. Thanks in advance!

Comments

  • Gablux
    Gablux Member Posts: 81 Member
    edited November 2023
    Options

    if the velocity = 1 why do you need to kill these events?

    one tool you are missing is the function get_event_ids ()

    with it you can scan through the active events, check their EVENT_PAR_NOTE and EVENT_PAR_VELOCITY, if they match to your specifications, you can kill them.

  • medusa
    medusa Member Posts: 85 Helper
    Options

    Is this for MalletKAT?

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    edited November 2023
    Options

    Thanks for your reply. I would use a velocity of 0, but in Logic Pro, the lowest you can drag the velocity down to is 1. So I'm giving up the ability to use velocity 1 notes and instead using them to mute sounding notes. I'll experiment with the get_event_ids () function. Thanks again.

    I should also clarify, i don't want to kill notes with a velocity of 1. I want to use notes with a velocity of 1 to trigger note-offs for all singing notes with that same pitch. Imagine a complicated vibraphone passage with the sustain pedal active. And just one or two notes sound bad with the next chord. All I want to do is sequence mutes for those notes only and leave the sustain pedal active. Hope that makes sense.

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    Options

    Sort of. I'm sequencing MIDI for vibraphone in Logic, and then importing it into Sibelius. I just want to use an X notehead on Sibelius to act as mallet mutes that will override the status of the sustain pedal.

    Do you know of a script that already does something similar?

  • medusa
    medusa Member Posts: 85 Helper
    edited November 2023
    Options

    Something like this? (EDIT, sorry this is a mute, my mistake, change the fade_out to a note_off...)


    on init
        declare $count
        declare %array[512]
    end on
    
    on note
    if ($EVENT_VELOCITY < 2 )
        get_event_ids(%array)
        $count := 0
        while($count < 512 and %array[$count] # 0)
            if( get_event_par(%array[$count], $EVENT_PAR_NOTE) = $EVENT_NOTE )
                fade_out(%array[$count], 300000, 1)
            end if
            inc($count)
        end while
    end if
    end on
    
    
    
    
  • realdealpeel
    realdealpeel Member Posts: 20 Member
    Options

    Even the fade-out works great!!!!!

    Please message me directly so I can pay you.

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    Options

    While you're here, I did try replacing

    fade_out(%array[$count], 300000, 1)
    

    with

    note_off(%array[$count])
    

    and it won't work. But in case you're busy the fadeout works fine for now, I'll just shorten it a bit. :)

    Been trying to figure this out for 3-4 days straight so will happily send you some thank you cash if you message me.

  • medusa
    medusa Member Posts: 85 Helper
    Options

    Haha... you don't have to pay me, it's just something I did for MalletKat a while back.

    Not sure why note_off isn't working for you, maybe some other part of the script is affecting the release?

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    Options

    Hmm, it could be several things. I'll experiment and come back if I figure it out. This gets me 99% there though, so thanks so much for your knowledge!

  • stephen24
    stephen24 Member Posts: 282 Pro
    Options

    Thanks for a very instructive thread.

    The principal problem is overriding the sustain pedal which I don't think can be done (note_off obviously won't release the note if the pedal is down). Fade_out is a brilliant workaround.

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    edited November 2023
    Options

    That makes sense.

    So far, the fade_out is working fine. There's literally not a single bug or issue with this script and it's clean and tiny.

    If someone really needs the note_off() function though, one could change the sustain pedal with the 'on controller' callback before the 'on note' callback. Make it so note_off($ALL_EVENTS) will replace C64,0, and ignore note-offs for all note events before the if($EVENT_VELOCITY < 2). I'm not good enough yet to figure out the proper order of things but I imagine it could be done.

  • stephen24
    stephen24 Member Posts: 282 Pro
    Options

    Ah - remember cc64=0 doesn't release all notes, only those which have had a note-off.

  • medusa
    medusa Member Posts: 85 Helper
    edited November 2023
    Options

    If you need the note_off to work while the sustain pedal is down, I'd say you're going to need to write your own sustain pedal routine, and SET_CONDITION(NO_SYS_SCRIPT_PEDAL)

  • realdealpeel
    realdealpeel Member Posts: 20 Member
    Options
Back To Top