What's new

No note off on pedal release or CC64 off messages

KrisY

Noob in frenzy loop
Hey everyone! I´ve got a peculiar issue. I cannot get the controller CC64 (pedal off message) to release a key being played. I use note_off and i´ve got the SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG) on init, it´s a custom release script. I am also entering in event parameters in each event on note, by using $EVENT_PAR_1. Then, on release, I intercept this parameter to divide the events up into 2 groups. One for events played with the pedal off and the other for when the pedal was pressed.

On release with CC64 on 63 or less (pedal off), the script releases the notes and plays 2 new notes, one for string release, one for a key sound. All is well here. But on release of the pedal, the release is played (only key sounds), but the initiating key, the "sustained" note, is not released.

Code:
on init

    { GROUPS INFO:

    groups in instrument: 5.

    0: Pedal OFF sustains. 1: Pedal ON sustains. 2: string release. 3: Key release.
    4: group for key 16, trigger for on release cc64 pedal off message. }

    declare polyphonic $new_id_poff
    declare polyphonic $new_id_pon

    declare polyphonic $new_id_poff_note_off
    declare polyphonic $new_id_pon_note_off

    declare polyphonic $key_off_sound

    declare polyphonic $evpedal_state

    declare $pedal_off_message

    $evpedal_state := 0
    $pedal_off_message := 0

    message("initiated")
    SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)

end on

on note

ignore_event($EVENT_ID)

    if (%CC[64] < 64)

        disallow_group($ALL_GROUPS)  {allowing only first group, for pedal OFF sustain samples}
        allow_group(0)

        $new_id_poff := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
        set_event_par($new_id_poff,$EVENT_PAR_1,0) { set event par 1 to OFF, 0, or POFF }

    end if

    if (%CC[64] > 63)
        disallow_group($ALL_GROUPS) {allowing only second group, for pedal ON sustain samples}
        allow_group(1)

        $new_id_pon := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
        set_event_par($new_id_pon,$EVENT_PAR_1,1) { set event par 1 to ON, 1, or PON }

    end if

end on


on release

    $evpedal_state := get_event_par($EVENT_ID,$EVENT_PAR_1)

    message("evpedal_state is: " & $evpedal_state)

    if ($EVENT_NOTE >= 15 and $EVENT_NOTE <= 108)


        if (%CC[64] > 63 and %KEY_DOWN[$EVENT_NOTE] = 0)

            { always KEY release, here it´s when pedal is pressed. }

            disallow_group($ALL_GROUPS)
            allow_group(3)

            $key_off_sound := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
            change_vol($key_off_sound,4000, 0)

        end if


        if (%CC[64] < 64 and %KEY_DOWN[$EVENT_NOTE] = 0)
            
            if ($evpedal_state = 0)  { pedal OFF string release }

                disallow_group($ALL_GROUPS)
                allow_group(2)

                note_off($new_id_poff)

                $new_id_poff_note_off := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
                
            end if

            if ($evpedal_state = 1)  { pedal ON string release, same group, separate volume, for testing }


                disallow_group($ALL_GROUPS)
                allow_group(2)

                note_off($new_id_pon)

                $new_id_pon_note_off := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
                change_vol($new_id_pon_note_off,8000, 0)


                message("evpedal_state is: " & $evpedal_state)

            end if


            { always KEY release }

            disallow_group($ALL_GROUPS)
            allow_group(3)

            $key_off_sound := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
            change_vol($key_off_sound,4000, 0)
            
        end if



        { if the pedal is released, aka, if pedal_off_message is played. }

        if ($EVENT_ID = $pedal_off_message) 

            disallow_group($ALL_GROUPS)

            message("evpedal_state is: " & $evpedal_state & ". And pedal off message here.")

            {obs only do anything with keys and release, if the key_down is 0. }
            if (%KEY_DOWN[$EVENT_NOTE] = 0)

                note_off($new_id_poff)
                note_off($new_id_pon)

                allow_group(2)

                $new_id_pon_note_off := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)
                change_vol($new_id_pon_note_off,8000, 0)

            end if
            
        end if
        
    end if

end on


on controller

    if ($CC_NUM = 64 and %CC_TOUCHED[64] = 1 and %CC[64] < 64)
        
        { solution to trigger a note with the intent to interpret this action in the on release...  }
        { ... to be able to identify the pedal as the root cause for the release event. }

        $pedal_off_message := play_note(16,1,0,0)
        set_event_par($pedal_off_message,$EVENT_PAR_1,3) { set event par 1 to 3, so we can see it on release }

        {ANCHOR 2: here´s where I would put the two note_off messages for Pedal OFF and ON sustain sample groups. }

        note_off($pedal_off_message)
        
    end if

end on


I have tried with and without:
SET_CONDITION(NO_SYS_SCRIPT_PEDAL)

I have tried putting the note_off message in on controller: (ANCHOR #2 in code above)
note_off($new_id_poff)
note_off($new_id_pon)

No luck. Any help would be greatly appreciated.

I have a few solutions lined up, but I cannot see the issue, isn´t the note_off message enough to make the Pedal ON group stop playing?
 
OP
K

KrisY

Noob in frenzy loop
In the "on controller" section, try insert else just before note_off($pedal_off_message)
Interesting, but what is the function we hope to get out of that? the note_off message there is the trigger for the RCB at release of the pedal. It is supposed to first say play_note (and just play a bogus empty note for no time at all), then immediately release it via note_off, thus producing an EVENT_ID that can be "intercepted" in the resulting RCB, whereupon it is then handled separately from the other RCB triggers. I want to trigger a note off all events that have no key down, to clear the deck, so to speak.

Or do you mean because there is no "else" statement at all, that it is not functioning properly?
 
Top Bottom