1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Trigger looped sample by switch script?

Discussion in 'Scripting Workshop' started by etothedizzy, Feb 12, 2014.

  1. etothedizzy

    etothedizzy New Member

    Messages:
    23
    I just noticed that MIDI Monitor reports the following when pressing STOP:
    Code:
    Controller: 123  Value: 0
    Pitch Bend  Value: 0
    Any help guys? Thanks, I think this problem is close to being solved. I can feel it!
    I need some sleep...
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    All Notes Off is CC123, so how about if we try and ignore it from a multiscript?

    Code:
    on midi_in
        if ($MIDI_COMMAND = $MIDI_COMMAND_CC and $MIDI_BYTE_1 = 123)
            ignore_midi
        end if
    end on
    What happens now?
     
  3. etothedizzy

    etothedizzy New Member

    Messages:
    23
    It''s the same as before.
    FL has a fully functioning demo (no time limit, you just cant reopen saved sessions) if you guys feel inclined to see this craziness in action. Are there other CCs that could be sending All Notes Off?
     
  4. Big Bob

    Big Bob Forum Member

    Messages:
    606
    7B is hexadecimal for 123. What the 16 MIDI messages are doing is issuing an All Notes Off (CC123) for all 16 MIDI channels.

    However, since you are disabling All Notes Off in Kontakt, the mystery still continues as to why this should stop your script-triggered noise sample.
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Well, one thing that crosses my mind is that Kontakt itself isn't fully filtering All Notes Off in some circumstances (like when responding to a particular DAW's transport messages) despite the checkbox being checked... In this case, that would be Kontakt's bug, and waiting for that to be fixed might take a long while (and for all we know, it might never be fixed :/).
     
  6. etothedizzy

    etothedizzy New Member

    Messages:
    23
    Well if it IS a bug, then I guess I have no choice but to find a decent work-around. I'm thinking of having the noise loop playing constantly, and only having a switch that simply MUTES the whole instrument, rather than having it bypass just the noise. Does this change anything? Would it be possible to simply have the noise loop re-triggered once Kontakt receives an "all notes off" message? I'm assuming I may have to use some sort of short delay to make sure that it re-triggers only AFTER all of the "all notes off" messages are received. How would I script a note to play after an "all notes off"?
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Well, you could try something like this, perhaps...

    Code:
    on init
        declare $ID
    
        set_listener($NI_SIGNAL_TRANSP_START,1)
        set_listener($NI_SIGNAL_TRANSP_STOP,1)
    end on
    
    on listener
        select ($NI_SIGNAL_TYPE)
            case $NI_SIGNAL_TRANSP_START
                $ID := play_note(0,127,0,-1)
            case $NI_SIGNAL_TRANSP_STOP
                note_off($ID)
        end select
    end on
    Instead of using a switch, this will start a note every time host's transport is started, and stop it when it's stopped.
     
  8. etothedizzy

    etothedizzy New Member

    Messages:
    23
    Okay I think we're getting somewhere. It's working pretty good, but upon pressing STOP a second time the note is turned off once again. Ideally the noise would start on init, and there would be no way to turn the noise off unless you muted the whole instrument. And even THEN it would still be "looping", you just wouldn't hear it.
     
  9. etothedizzy

    etothedizzy New Member

    Messages:
    23
    How about an "on release" callback to re-trigger the noise once the "note off" is received?
     
  10. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    All notes off doesn't equal to note off event...

    How about this:

    Code:
    on init
        declare $ID
        set_listener($NI_SIGNAL_TRANSP_START,1)
        set_listener($NI_SIGNAL_TRANSP_STOP,1)
    end on
    
    on controller
        if (%CC_TOUCHED[123] = 1)
            ignore_controller
        end if
    end on
    
    on listener
        select ($NI_SIGNAL_TYPE)
            case $NI_SIGNAL_TRANSP_START
                $ID := play_note(0,127,0,-1)
        end select
    end on
     
  11. etothedizzy

    etothedizzy New Member

    Messages:
    23
    Got it. This is better, still the noise gets cut on pressing stop more than once. I wonder if pressing stop twice does some sort of reset or refresh in Kontakt.
     
  12. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    I wouldn't know, but why do you need to press stop twice anyways?


    In any case, I can't reproduce that in Reaper... why not use Reaper if the issue doesn't manifest in it? :)
     
  13. etothedizzy

    etothedizzy New Member

    Messages:
    23
    I press stop twice to quickly kill all audio from sustaining. Long reverbs and delays for example. It's sort of become a workflow thing so I always click it twice. It IS useful. Hmmm...what sort of messages could be sent to a plugin to kill all of its output? FL doesn't simply mute the plugin, it actually causes it to stop generating sound weather it be an instrument or an effect.

    I don't think any problem should go unsolved. So rather than throwing in the towel, I'd much prefer to fix what is broke...or at least find an answer as to why Kontakt is behaving this way. Thanks for the help thus far! It is really appreciated.
     
  14. etothedizzy

    etothedizzy New Member

    Messages:
    23
    How would I script a version of this:
    Code:
    on controller
      if ($CC_NUM = 123)
        ignore_controller
      end if
    end on
    but while specifying each of the 16 MIDI channels? I was thinking that FL sends 16 different "all notes off" messages and perhaps my script needs to be equally redundant.
     
    Last edited: Mar 3, 2014
  15. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    If the instrument is in OMNI mode, then the above code should filter the CC coming on any MIDI channel. Alternatively, if the multiscript posted on previous page doesn't prevent audio from being killed when you press Stop twice, then it might be that this isn't even Kontakt's problem, rather FL Studio purging the audio buffers on second press of Stop button. This might have nothing to do with All Notes Off being sent... Because Reaper doesn't behave like this, I'm thinking this is likely what's happening here.
     
  16. etothedizzy

    etothedizzy New Member

    Messages:
    23
    I decided to do an experiment. I loaded one of my Waves API plugins (effect) and turned the "Analog" switch on. In case you're unfamiliar with these "Analog Emulation" Wave's plugins, this switch outputs a noise floor similar to what I am trying to achieve with Kontakt. Assuming that FL purges the audio buffers, THIS generated noise should also be killed on hitting Stop twice. When I tried this there was no change. The noise floor continued to output regardless of FL's panic trigger. I went on to load Kontakt as an effect with my instrument, but the same problem persists.
     
  17. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    I'm out of ideas here. I think plenty of workarounds have been posted, pick one. :) As this seems specific to FLS <-> Kontakt, I wonder if it's ever going to be fixed, since it's such a rare usage scenario...
     
  18. etothedizzy

    etothedizzy New Member

    Messages:
    23
    You may be right. I'll keep at it though.
     
  19. etothedizzy

    etothedizzy New Member

    Messages:
    23
    So I am going to move forward and put this issue on the back burner for now. Thanks for the help guys!

    I'm attempting to work out the script so that the noise floor loop is triggered on Play and Stop, but also on any single note event. This would be the perfect workaround since the noise would be triggered as soon as you hit any single note. Of course I'm having trouble though. I got it to work, but I need to avoid the noise loop being retriggered (restarted) if it's already playing. Basically ignoring all of the trigger callbacks, but only if it's ACTUALLY playing. And lastly, I would LIKE the noise floor to be triggered as soon as the instrument is loaded. I couldn't get this to work under "on init" and don't even know if it's possible. I have been experimenting with workarounds, but I clearly have a LONG way to go in my scripting abilities.
     
  20. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You cannot start any note events on init - that's why I used listener callback above.

    Use event_status() to query an event ID if it's playing and then decide what to do if it is, or it isn't - there's an example on how to use this command in the KSP reference.