PDA

View Full Version : Is there a bug in the KSP?



Big Bob
06-27-2005, 07:56 PM
Try the following experiment. Load some instrument with sustained tones, like an organ. Clear any existing Script and then enter this simple 3-line script:

on note
play_note ($EVENT_NOTE - 12,$EVENT_VELOCITY,0.-1)
end on

Click 'Apply' and try it.
This simple script simply doubles any key you hit with the same pitch an octave lower. The created octave should last until you release the key that caused it.

Now, here's the problem. Take a finger and sweep it back and forth across your keyboard, playing rapid glissandos. After a few swipes, notes will begin to get stuck on.
This of course shouldn't happen.

I think we've got trouble right here in River City!

T. S.
06-27-2005, 09:43 PM
Hi Big Bob,


Try the following experiment. Load some instrument with sustained tones, like an organ. Clear any existing Script and then enter this simple 3-line script:

on note
play_note ($EVENT_NOTE,$EVENT_VELOCITY,0.-1)
end on

Click 'Apply' and try it.
This simple script simply doubles any key you hit with the same pitch an octave lower. The created octave should last until you release the key that caused it.

Now, here's the problem. Take a finger and sweep it back and forth across your keyboard, playing rapid glissandos. After a few swipes, notes will begin to get stuck on.
This of course shouldn't happen.

I think we've got trouble right here in River City!

I tried this just like you said and not only didn't I experience any stuck notes, I also didn't get any octave notes.

What I did find is that the scpript editer (almost anything to do with text in Kontact) is extremely "buggy". I think that's probably another topic in itself.

Is the syntext (or what ever you call it) you have here exactly right?

T. S.

Big Bob
06-27-2005, 09:52 PM
Whoops!, I see that I left out the -12. The first parameter of the play_note function should be $EVENT_NOTE - 12. Sorry, let me try to fix this but it's probably too late to edit the original post.

Nope, it wasn't too late, I just corrected it. Sorry for the mistake. Try it now.

T. S.
06-27-2005, 10:00 PM
Got it Big Bob,

The octaves worked great but I didn't experience and stuck notes. I'm useing the stand alone version of Kontact. I ran my fingers up and down the keyboard many times and no stuck notes.

T. S.

Big Bob
06-27-2005, 10:23 PM
Maybe my 'finger' is faster than yours:confused: ? I too was running in standalone mode. To exonerate my keyboard, I concocted a sequence running up and down the C major scale at a pretty good clip. As long as the duration of the notes are shorter than the separation between notes, the problem doesn't seem to occur. But, as soon as the notes overlap by 25% or so, the problem occurs within a half-dozen or so glissandos. Furthermore, if I 'Bypass' the script and then run the same sequence or use my magic sliding finger, I can't produce the problem. For my money, this pretty well points the finger at the KSP.

If no one else can produce this problem, then maybe it's some horrible thing like the KSP doesn't like running properly on my hardware! If anyone else can reproduce this problem, please let me know. Thanks.

T. S.
06-28-2005, 12:48 AM
OK Big Bob,

I did manage to get notes to stick 'Sounding on" twice. This was after many many tests with different organs. However, most of the time even though the notes weren't sounding, the keyboard at the bottom of Kompact indicted that several notes were stuck on (the keys indicated as being depressed).

I did all this by basicaly laying my left hand and my right arm (up to my elbow :D ) down on the keybord and slowly then quickly moveing them up and down.

I then thought all this might be a polyphony problem so I set the #Voices to 120 and sure enough, the keys at the bottom them selves didn't stick any more.

Like I said I could only get notes to actualy stick on (sounding) twice and no matter what I did (set the voices to 16, etc.) I couldn't get it to happen again.

Exactly which instrument are you useing when this happens? Check the polyphony thing and see if that makes any difference.

Big Bob
06-28-2005, 11:02 AM
Hey T.S. thanks so much for your persistence. For you, and for the benefit of anyone else who is willing to help out here, let me elaborate a little to clarify things.

This problem is statistical in nature, probably due to some kind of 'race' condition between 'parallel' processes. Because it's statistical, it can be stubornly absent sometimes and annoyingly persistent at others. As the script gets more complex, the frequency of occcurence of this problem seems to rise. But also, when a script gets complex, the probability of an undiscovered bug in the script itself also looms large.

So, I attempted to reduce the problem to its essence with a script so simple that it itself can be eliminated from contention. Unfortunately, this simple script doesn't have as high a probability of producing the problem and sometimes you really have to work your 'sliding finger' to death trying to make it happen. However, it's not a polyphony problem because I can produce the problem without ever sounding more than a few notes simultaneously. As I indicated earlier, I have a simple MIDI sequence which will trigger the problem (if you run it long enough) and it never sounds more than two notes at once.

If your hardware configuration is such that you can run K2 in standalone mode and still drive it from your sequencer (via MIDI, out and back into your computer for example), I can attach a standard MIDI file that you can try. It's important to run K2 in standalone mode because there are just too many other potentially clouding issues when using K2 as a plugin. With K2 as a plugin we have to deal with interactions between K2 and the host sequencer (and just a casual glance at the forums will reveal how many subtle issues come up that way).

Let me spend a little time to see if I can't concoct a better little script that causes the problem to appear more easily. In the meantime, if you'd like to try this one, I think it will cause the problem more frequently. This script generates 3 chord tones for each key you hit and this makes it more probable that the problem conditions will arise in a given period.

on note
play_note($EVENT_NOTE - 12,$EVENT_VELOCITY,0,-1)
play_note($EVENT_NOTE - 5,$EVENT_VELOCITY,0,-1)
play_note($EVENT_NOTE - 8,$EVENT_VELOCITY,0,-1)
end on

Let me know if your willing to try the sequencer thing, etc.

Thanks again for you willingness to help.

Big Bob
06-28-2005, 12:19 PM
I'd like to attach a Standard MIDI file to this post, but apparently that feature isn't enabled for me. However, I'm also going to post this on NI's forum where I can upload an attachment, please download it there.

This Standard MIDI file of up and down glissandos. This sequence is 36 bars long and consists of 4 bars of glissandos followed by 2 bars of silence. This 4-2 pattern is repeated six times. The reason for the pauses is so that you can hear if there are any stuck notes (they're harder to hear while the glisses are happening). Also, you can't just stop the sequence to listen for stuck notes because most sequencers send an 'all notes off' message when they stop.
I've been using an organ from the K2 library titled 1960s E_Organ.nki. With this sequence and even the simple form of the script (the 3-line octaver) the problem occurs quite regularly. On very rare occassions, I can get all the way thru the sequence without a stuck note, but, most of the time stuck notes occur almost once per 6 bar pattern.

Again, I need to emphasize that you should try to run K2 in stand alone mode. You can do this if you simply send your sequencer output to a real hardware MIDI connector and then send it back as a hardware input to K2.

Meantime, I'll work on a more sensitive script for those of you who can't do the sequencer thing, but can do the experiment with your keyboard.

fizbin
06-28-2005, 02:11 PM
Which notes are hanging - the actual played note, the triggered (play_note) notes, or both?

You could put a counter and a message in the "on release" event to know if all the note offs are being triggered as an aid to troubleshooting. For instance, if in the on "note event" you only have a a single "play_note" then your count should always be an even number as in the following example.


on release
inc(count)
message(count)
end on


This will show the total number of note release/note offs and if it is an odd number or a number that is not a multiple of however many "play_notes" are in the "on note" section plus one (for the original note) then that might get us a step closer to sussing this out.

I've had a bit of experience with the scripting and have not experienced the issue that you are experiencing. Have you updated to the latest version of K2? I think there has been a single update since its initial release.

Regarding the race condition theory - it could very well be a threading issue, but its impossible to tell without real debugging. I'm running a P4 with hyper-threading enabled, not that multi-proc would be necessary to cause the race condition. Have you contacted NI support about this?

fizbin

Big Bob
06-28-2005, 03:29 PM
Hi Fizbin.

Thanks for your suggestions.


Which notes are hanging - the actual played note, the triggered (play_note) notes, or both?

It's a little hard to tell, just by the sound, but I suspect it may be the generated note(s).


You could put a counter and a message in the "on release" event to know if all the note offs are being triggered as an aid to troubleshooting. For instance, if in the on "note event" you only have a a single "play_note" then your count should always be an even number as in the following example.


Actually I've done a lot of just that sort of thing, especially when I first experienced the problem with the complete script that I was developing. I'm routinely using 4 edit boxes when debugging so that I can display several counts at the same time. In addition, I'm using two ui_tables of 12 elements each to display octave-independent pitch data. Every such tally that I could devise indicated the expected parity, yet notes were still left on. I'm an old, embedded microprocessor programmer from the 'dark ages' before fancy debuggers were available. So I'm very familiar with using whatever primitive thing might be available to get a handle on where things are going wrong. And, since it wasn't showing up anywhere that I could see, I was beginning to suspect that it might be a problem in the KSP machinery itself. But your suggestions are very appropriate.


I've had a bit of experience with the scripting and have not experienced the issue that you are experiencing. Have you updated to the latest version of K2? I think there has been a single update since its initial release.


I do have the latest version of K2. And, I'm glad to hear you say that you haven't yet experienced this problem. If you read this thread, you may have noticed that T.S. hasn't been able to produce the kind of error rate that I'm experiencing either. It's beginning to smell like I may have a problem with something other than K2.

It also looks like I might have been hoisted on my own pitard! I wanted to avoid the additional problems that might have arisen from running in plugin mode, so I've been doing all my testing in standalone mode. However, since both you and T.S. have indicated that you're not having the same problem,
just for kicks, I ran my test MIDI sequence using K2 as a plugin and lo and behold, I haven't been able to get a failure! The common denominator (on my system) when running K2 standalone, is an old Roland UM-2 MIDI interface and I'm beginning to think it may be playing at least some part in this problem. I have a fairly recent driver for it but not the latest. I'll update the driver later today and I'm also going to re-run all the tests using my AP2496 MIDI I/O. Unfortunately this won't be easy to do because of the way I've got things cabled. But, then (sigh) nothings easy is it?

I'll post again as soon as I know something. Thanks again for your input.

fizbin
06-28-2005, 03:41 PM
Try recording the output of the Roland UM-2 MIDI onto a MIDI track in your host and then you'll see any hung notes and it will be apparent if that is causing the problem.

fizbin

Big Bob
06-28-2005, 04:24 PM
Hey Fizbin, good suggestion. I'll try that.

However, since plugin works and standalone doesn't, the possibility still exists that there's something amiss in K2's front end when receiving data from a MIDI driver as opposed to obtaining it via Dx. I'll know more later today.

BTW, since you've been using the KSP longer than I, have you ever had occasion to see what number range is used by NI for assigning as Event IDs? I have seen values as high as 4999. I'm hoping that only a subset of the full integer range (which I assume is that of 32-bit signed integers) is utilized for event tagging. The reason I'm interested is that there are programming situations in which it's convenient to have a value that can be used for an event ID variable that is guaranteed to never match any legitimate ID. Since I have never seen a negative number used, for now I'm using -1 as my token for 'No_Event'. Zero would of course be more convenient if I knew for sure that the KSP doesn't use it. I've asked Alan at Sonic Control to look into it and see if he can find anyone at NI that might know, but in the meantime I think we're stuck with the empirical method. If you have observed a range of ID numbers or have any first-hand knowledge of this, I'd appreciate hearing from you. Thanks again for your excellent suggestions.

fizbin
06-28-2005, 04:42 PM
I'm not sure what the range is. What situations would you have to use a non-valid ID? It seems that logically you might be able to accomplish your goal another way regarding this. Maybe I'm not understanding the scenario in which this would be necessary.

fizbin

Big Bob
06-28-2005, 07:19 PM
Hi again fizbin,

This is just one of many old programming tricks that can save an extra compare instruction or two. Of course it can be done in other ways if we don't have a good token, but, in the early days when we were stuck with small memory, slow processors, and the need to execute an algorithm fast (because it was used as part of a real-time process control loop), we would look for anything that could save us an instruction or two.

There are several ways that the token or 'impossible value' scheme is used but, one of the most common is when a loop is iterating a value. For example, if X is equal to the last value of X we do routine #1. Whereas, if X is not equal to the last value of X, we set Last_X := X (ie we update X) and then do routine #2. When we start this loop there is no Last_X yet. However, if we can initialize Last_X to a value which can never equal X, then we can use the same simple test at the head of the loop because we know it will fail and force an update of Last_X. If this isn't too clear, when I get time to catch my breath, I'll illustrate the idea with a real routine for the KSP.

In the meantime, I've got some test results and they don't look too encouraging. I've been able to exonerate my UM-2 MIDI interface in two different ways. The first thing I did was to try your idea of recording my keyboard glissandos. The sequence that was recorded had no elongated (stuck) notes. Yet when this recorded sequence is played back into K2 via MIDI loop back, stuck notes audibly appear. Then I used a totally different MIDI interface and repeated all the experiments. Again the KSP generates hanging notes. Now, since the stuck note problem doesn't seem to occur if I feed the same data to K2 as a plug in, there may just be some kind of problem with K2's standalone front end.

If you can spare the time, please download my MIDI file(s) and try it on your equipment. I'm going to add another MIDI file with the new recorded keyboard glissandos since it seems to aggravate K2 even more than my first posting. However, since I apparently don't have 'attachment' privileges on this forum, I'll post the new MIDI file on NI's forum.

Big Bob
06-28-2005, 10:13 PM
More bad news! Since the second MIDI file that I posted seems to be better at aggravating the stuck note mechanism in K2, I thought I'd recheck the plugin mode. Whereas I couldn't produce the problem with the first MIDI file, this second file brings it on right away -- even in plugin mode.

However, in a way, this may be good news. I know that a lot of you aren't set up to play a sequence into K2 running in standalone mode. But now, we have a MIDI file that you can play in plugin mode that should produce the problem.

In the light of this, I hope that more of you will try this experiment to see if you can also reproduce this problem. All you have to do is download the .zip file (that I posted on NI's forum) and unzip the standard MIDI file it contains. Load a K2 organ patch into the rack (I've been using the one named '1960s E-organ.nki') and add the simple 3-line script below (be sure to hit the 'Apply' button). Then just play the second MIDI sequence (a few times if necessary) and you should hear stuck notes.

on note
play_note($EVENT_NOTE - 12,$EVENT_VELOCITY,0,-1)
end on

Incidentally I contacted the webmaster for this forum and was told that attachments are disabled system-wide because of insufficient bandwidth. But mosey on over to NI's Kontakt forum and you'll find the MIDI files in my thread by the same name as this one.

T. S.
06-29-2005, 10:11 AM
Down loaded your midi file, loaded it into Sonar-4 and Indeed Big Bob, it did stick notes. The funny thing is that stuck notes usualy show up on the K2 keyboard but none were indicated?? :confused:

T. S.

Big Bob
06-29-2005, 11:35 AM
Thank you T.S. for helping me to preserve my sanity. I was beginning to think that only I was singled out to have this problem.

The 2nd MIDI file is much better at producing the problem than the first one. I made the first one mechanically by step entry while I tried to experimentally determine the kind of thing that the KSP was sensitive to. The 2nd MIDI file came about because of fizbin's suggestion (as a means to check out my UM-2 MIDI interface). Fortunately the recorded glissandos appear to be very good at aggravating the KSP.

I think I'm going to edit the 2nd MIDI file to add some silence at the end and then repeat the whole deal a few times like I did with the first MIDI file. Then, because I was still trying to get a handle on the problem when I started this thread, It has become rather dis-jointed. So, I think I'm going to re-post this problem as a new thread to sort of start fresh. I'm hoping that more K2 users will then try this test so we can verify that this is a universal problem and hopefully, get NI to do something about it. Thanks again for your help T.S.

Whoops! I guess I should have looked at the recorded glissandos a little more carefully. While there aren't any permanently stuck-on notes, I just noticed that there are many elongated notes that hang until the same pitch comes along again. I think my idea of re-posting has real merit but first I better go off line long enough to get my act together. There definately are some problems here but I need to characterize them better. I'll be back!

fizbin
06-29-2005, 01:53 PM
So, since hung notes are showing in the 2nd MIDI file itself, that would indicate a problem perhaps with your MIDI interface (and perhaps not with K2)? Sorry, but I can't check it myself just now as my gear is three quarters packed away for a move.

fizbin

Big Bob
06-29-2005, 08:10 PM
fizbin, that's what I thought at first too, but, no such luck. I don't know what I was smoking when I made that file but I now have several glissando files with no elongated notes but they still mess up K2.

I also have some concrete evidence now that there is at least one problem in the KSP, however, there is some good news. I'm hot on the trail of just what the problems with the KSP are. But, I want to get it fully characterized before I report anything. Because of its seemingly random nature, it's been difficult to pin down. So hang in there everyone and when I return I'll have some answers and possibly even some workarounds.

I'll shall return!

T. S.
06-29-2005, 10:46 PM
Hi Big Bob,

I Love yah, you are certainly persistent and I'm glad you are. Your beyond me when it comes to this sort of thing but I'll help when I can.

By the way, did you check out that thread I gave you? It's realy kind of neat.

T. S.

Big Bob
06-30-2005, 10:00 AM
Hi T.S.

I sent you a private message in response to yours, but maybe it didn't get to you (or maybe you haven't checked?). I checked the link you sent me but I only had time to scan it quickly. I did however bookmark it and I'll get back to it as soon as my KSP headache subsides. BTW I'm going to send you another personal message today to see if you'd be willing to do a little experiment for me before I post the results of my KSP investigation. I'll talk to you soon.

Bob

Big Bob
07-04-2005, 05:45 PM
Hey guys, for the thrilling sequel to this, see my new thread titled 'Timing Problems with the KSP'.