Does blip-note trick work inside on release callback?

Discussion in 'KONTAKT: Sampling, Programming & Scripting' started by olmerk, May 13, 2019.

  1. olmerk

    olmerk Member

    98
    5
    Nov 1, 2015
    Hi! Has anyone tried to use famous blip-note trick inside on release callback, i.e. when the blip-note is fired from out there.

    I suspect that in this case blip-note end (release) never reaches on release callback to start a block of script I placed there particularly for it.

    A "catcher below displays nothing:

    Code:
    on release
    
    if (get_event_par($EVENT_ID,$EVENT_PAR_SOURCE)#-1)
        add_text_line($monitor,"blip-note, " & EVENT_ID & " ," & blip_id)
    end if
    
    end on
    
     
  2. EvilDragon

    EvilDragon KSP Wizard

    6,106
    3,975
    May 25, 2010
    Croatia
    If you fire it from RCB, you're triggering a note on, so your event par checking should be in NCB, not RCB.
     
  3. OP
    OP
    olmerk

    olmerk Member

    98
    5
    Nov 1, 2015
    So it works like in reverse? NCB->blip-note->RCB and RCB->blip-note->NCB?
     
  4. EvilDragon

    EvilDragon KSP Wizard

    6,106
    3,975
    May 25, 2010
    Croatia
  5. I came across this issue a while back:

    A scripted 'note_off' in NCB for a note generated in the RCB will not trigger the RCB.
    A scripted 'note_off' in NCB for a note generated in the NCB does trigger the RCB.
    A scripted 'note_off' in RCB does not trigger another RCB at any time.

    NCB (Note Callback)
    RCB (Release Callback)
     
  6. Levitanus

    Levitanus Active Member

    mutually exclusive paragraphs
    UPD: sorry, wrong written... Maybe you're right. Don't remember exactly...

    Generally, RCB is triggered pretty often, which causes many on if-blocks:
    - when an event is taking off
    - when a sample played to end
    - when a key goes up

    so, let's go through the cycle:

    1. key A pressed, NCB with ID 1 executed
    2. key B pressed, NCB with ID 2 executed
    3. scripted note-off event for the ID 1: RCB with ID 1 executed
    4. key B released, RCB with ID 2 executed
    5. scripted note event at note A started by RCB ID 2, - NCB with ID 3 executed
    6. key A released - oops, RCB with ID ??? {1? 4?, definitely not 3} executed (I'm too tired to check it)
    You can look to my code that works not bad (but not ideally) in test.rar. (with WARP trumpet samples)

    the txt is much more dirty, but with nirmal names and comments. It is WIP, but I've leaved it for a big while
     

    Attached Files:

    Last edited: May 13, 2019
  7. OP
    OP
    olmerk

    olmerk Member

    98
    5
    Nov 1, 2015
  8. EvilDragon

    EvilDragon KSP Wizard

    6,106
    3,975
    May 25, 2010
    Croatia
    olmerk and Levitanus like this.
  9. andreasOL

    andreasOL Active Member

    267
    30
    Jan 9, 2010
    Hesel
    Well, to either enhance confusion or clarify things :) and to go back to the original question IIRC if you do the blip-note (scripted play_note) in the RCB that blip-note triggers nothing in the same script slot (only in following script slots). If I use blip-notes I start them in the NCB and catch them in the same script slot's RCB. If you have logic in the RCB that wants to use a blip-note to start a backgroud loop in the same RCB a work around can be to initiate a PGS event with a play_note in the PGS callback which (again: IIRC) then at least passes through the RCB (but also not the NCB). However, perhaps it's worth rethinking the overall logic and what happens where. Another idea can be to start the background loop (if that's the intension) directly at the end of the RCB (where you are at the time when the decision to fire the blip-note is made) so just skip the blip-note because you are already where to want to go to (so to speak)...

    just my thoughts...
     
  10. neblix

    neblix Music, Math, Cats

    255
    247
    Jul 22, 2010
    Philadelphia, PA
    @olmerk Blip notes don't work in the RCB. Use a hidden ui_switch attached to a CC instead. Use set_controller() to fire the callback.
     
    Last edited: May 29, 2019
    olmerk likes this.
  11. OP
    OP
    olmerk

    olmerk Member

    98
    5
    Nov 1, 2015
    Thanks a lot! Where can I read about the hidden button trick to get more details?
     
  12. neblix

    neblix Music, Math, Cats

    255
    247
    Jul 22, 2010
    Philadelphia, PA
    Probably nowhere. But that's all you really need to know:
    1. Make a ui_switch (made an error before, has to be a switch).
    2. Go to Kontakt Automation tab and drag a CC like 122 onto it to map it. This has to be saved in every nki you want to use this scripting technique in.
    3. set_controller(122, [any value]) will immediately press the button. You can call this from basically any callback or function, and additionally other script tabs. It will all work.
    4. Inside the button you can put whatever behavior you want that you had intended to put in the blip-note's RCB.
    5. Naturally, you probably wanted to deliver some important information for the callback's behavior. Things like note, velocity, or other pieces of data that would've been there as event parameters that you were reacting to in the RCB. You'll want to stuff whatever data you want to pass as arguments to the callback into an array before you call set_controller(). Inside the button callback, retrieve the data from the array.

    I use this technique in the latest engine powering Impact Soundworks products (not yet released).
     
  13. Fredeke

    Fredeke Active Member

    404
    138
    Jul 9, 2018
    Belgium
  14. EvilDragon

    EvilDragon KSP Wizard

    6,106
    3,975
    May 25, 2010
    Croatia

Share This Page