# Understanding release callbacks - Request for help



## kotori (Oct 1, 2006)

Hi everyone,
I and Bob are looking at the problem of voice-buildup in the SIPS Legato Script and run into some oddities with regards to how K2 runs release callbacks. If at the time of the first note-off message the event is ignored using ignore_event in the release callback, one would expect that the release callback would be invoked once again when the next note-off message arrives. On my computer the release callback is never run more than once as far as I can tell. On Bob's machine the release callback is almost always run every time a note-off message arrives, but suddenly the behaviour seemed to change and be like that on my computer for no apparent reason. We have yet not found any explanation which is why any help would be very welcome.

If you have time please help us understand the problem by trying the script below. Usage instructions:
1. load the script
2. play a single note and hold it pressed for a minimum of 5 seconds.
3. what does it say in the text display on the script? (please post your results)

If possible please try this procedure on both instruments with looped samples and instruments without looped samples and state which one you used (if you know this). If you post any results, please also state the version of Kontakt you used, whether it was on Mac or PC and whether it was in as a plugin or standalone.

Cheers,
Nils


```
on init
  declare $ReleaseCount
  declare ui_label $display(5, 6)   
  set_text($display, "")  
end on
 
on note
  set_text($display, "note_on")
  $ReleaseCount := 0 
  wait(1000000)
  add_text_line($display, "note_off called first time")
  note_off($EVENT_ID)
  wait(1000000)
  add_text_line($display, "note_off called second time")
  note_off($EVENT_ID) 
  wait(1000000)
  add_text_line($display, "note_off called third time")
  note_off($EVENT_ID) 
end on
 
on release
  inc($ReleaseCount) 
  if ($ReleaseCount < 3)  { skip the first two releases }
    ignore_event($EVENT_ID)
    add_text_line($display, "  release event ignored")
  else
    add_text_line($display, "  release event handled !!")
  end if
end on
```


----------



## kotori (Oct 1, 2006)

Here is the text which is displayed when I run the script (K2.1.1.001 standalone on PC):

note_on
note_off called first time
[tab]release_event_ignored
note_off called second time
note_off called third time

As you can see note_off only causes the release callback to run the first time.


----------



## Nickie Fønshauge (Oct 1, 2006)

Hi Nils,

I tried your script with the (1) VSL German Oboe K2 edition (unlooped) and the (2) GPO Oboe 1 Modern solo (looped) and the result is indeed odd.

With the first, the result is as expected and the note is cut off (prematurely, but correctly) when *note_off called third time* and *release event handled !!* pops up.

With the second, the note is cut off when *note_off called second time* pops up.

My system is WinXP SP2 Home Edition and Kontakt is version 2.1.1.001. This was stand alone. I get the exact same behaviour with the VST plugin. Also Sampler or DFD mode makes no difference.


----------



## kotori (Oct 1, 2006)

Thank you so much Nickie. An excellent report! It is still very interesting to hear about other people's findings, so please keep posting.
It's very strange Nickie, because when I use the Oboe (sustain).nki patch in the K2 Library I don't get the same result as you. In fact I get the same result as you do on the looped GPO Oboe and I get this result for all instruments I try.

The reason for the voice build-up in SIPS is that the release callback is not invoked in some situations and therefore code with the responsibility of turning off certain voices is never executed.


----------



## steff3 (Oct 1, 2006)

just a quick report

I get the same as you (second post) on Mac/standalone

hope I have a bit more time later


little addition(with looped and non-looped sounds):
voice always dies after the release event ignored.


----------



## Nickie Fønshauge (Oct 1, 2006)

This is interesting, Nils. I forgot to mention, that I used the KeySwitched X-fade version of the VSL German Oboe. The X-fade Sustain version (no KS) works similarly. BUT, the Standard Instruments (with/without KS) show the same behaviour as GPO.


LAST: You will find this *very* interesting, Nils. When I load the script (ALL instruments) in slot 1, I get the GPO behaviour. When I load them (ALL instruments) in slot 2, I get the VSL behaviour.


----------



## kotori (Oct 1, 2006)

Nickie Fønshauge @ Sun Oct 01 said:


> This is interesting, Nils. I forgot to mention, that I used the KeySwitched X-fade version of the VSL German Oboe. The X-fade Sustain version (no KS) works similarly. BUT, the Standard Instruments (with/without KS) show the same behaviour as GPO.
> 
> 
> LAST: You will find this *very* interesting, Nils. When I load the script (ALL instruments) in slot 1, I get the GPO behaviour. When I load them (ALL instruments) in slot 2, I get the VSL behaviour.



Nickie, I don't know how to thank you. You might really have found the key here. I'm seeing the same thing now, and that is a very good start. That second observation of yours is indeed VERY interesting. In the first slot the release callback is never run more than once, while in all other slots it runs multiple times when this is called for (the normal behaviour). This getting really crazy!

:!: *I advice everyone who uses SIPS not to load it in the first script slot until we understand this problem better*


----------



## Nickie Fønshauge (Oct 1, 2006)

kotori @ 1st October 2006 said:


> Nickie, I don't know how to thank you.



Just say "Check is in the mail" :razz: :lol: 

I am glad you can confirm the behaviour. It would have been really frustrating, if it behaved differently on different systems. Bad enough with different behaviour in different slots.


----------



## kotori (Oct 1, 2006)

I posted a bug report and general warning on the NI Forum. Thanks again Nickie!


----------



## Thonex (Oct 1, 2006)

This is very odd... and Nickie   very astute observation!!!

My results are like Nickie's but as follows:

I get the exact results of her second Pic when the script is in the first slot.

I get the exact results of her first Pic when the script is loaded in the second slot.

Very strange things indeed.

Great detective work guys... and great script Nils!!!!


Cheers,
T


----------



## kotori (Oct 1, 2006)

Thanks for confirming this Andrew. It's the same as on our computers then. Btw. in Nickie's first post two instruments were mentioned in one order and the images are presented in the opposite order (just in case someone would miss this).


----------



## Nickie Fønshauge (Oct 1, 2006)

kotori @ 1st October 2006 said:


> Btw. in Nickie's first post two instruments were mentioned in one order and the images are presented in the opposite order (just in case someone would miss this).


Not any more. But they were in opposite order before I added the "Note cut off" information to them. It did bother me, though.


----------



## Big Bob (Oct 1, 2006)

Hey Nickie,

I owe you a great big hug! I can't thank you enough for discovering this 'slot 1' problem and sharing it with us.  

I was tearing my hair out last night (what little I have left that is) trying to make sense of things. It was bad enough that Nils and I were getting very different results when we ran simple little test scripts but all sanity went out the window when suddenly I started getting two different results under what I thought were identical conditions. I started thinking I was living in some bizzare twilight zone.

When I sent my last email to Nils last night (after being forced to quit to preserve my sanity), I'm sure he must have thought that I had gone bonkers (I know I did :???: ).

Anyway, I can't tell you what a relief it was this morning when I awoke and starting reading about what you had discovered. Oh Hallelujah!

Thanks a million Nickie and have a beautiful day.

God Bless,

Bob


----------



## Nickie Fønshauge (Oct 1, 2006)

You are welcome, Bob. And I can imagine what you went through. When I first ran Nils' script on one of the VSL patches, it worked as it should. A few minutes later I loaded the same patch again to double check, and all of a sudden it didn't work anymore! Now, I don't really believe in the Twilight Zone, so I started looking for the cause. Luckily I happened to look in the right direction.


----------



## Dynamitec (Oct 2, 2006)

Wow! Great to know this. I once have rewritten a lot of my guitar script because it didn't run as expeced when i use release callbacks. And it never worked the way i wanted it too (that was one of the reasons i split it into more script slots). And know it seems that this was the problem! Thank you very much Nicke! This is really important.

Sorry that i don't have much time for this forum at moment. I'll have to do my first real KSP job *g*...but i'll be back. :wink:


----------



## kotori (Oct 2, 2006)

Dynamitec @ Mon Oct 02 said:


> [...]I'll have to do my first real KSP job *g*...but i'll be back. :wink:


Congratulations to the KSP job :smile:. I'm sure it'll be a success whatever it is your involved in Benjamin. Good luck! 

Cheers,
Nils


----------



## Dynamitec (Oct 2, 2006)

Thanks Nils and Bob!

Bob, i really know this problem...but it's the 'midnight oil' which sometimes burns best....


----------



## Big Bob (Oct 2, 2006)

Yes indeed,

At least while you're young :wink:


----------



## jibrish (Oct 3, 2006)

Another thanks to Nickie and Nils. I'm sure this saves a little hair pulling for more than one SIPS user.

BigBob - So glad to see you're putting out a few post here and there. (Missed your presence over at NS) and as I'm sure you know... SIPS is still much used and appreciated.

Peace.


----------

