KSP feature request, special play_note() option

Reid115 Member Posts: 47 Member

I'm not sure if there's a dedicated space for feature requests, so I'm just putting this here.

The play_note() function takes a microsecond duration parameter so the note knows how long to hold. Setting this to 0 makes the entire sample play, and setting it to -1 will play the sample indefinitely until the key that triggered the NCB is released. It would be extremely beneficial to me if there was some additional option to to say "play this note until you reach this point in the sample". So for example, if a sample is 1000k microsecs, I could tell it to play a note starting at the 200k point and release it at the 800k point (however long it takes to get there). Setting loop points will not work for what I'm doing. Currently, the only option is to create a very fast listener (mine is running at 1 millisecond) to constantly check if a given note has passed its cutoff point that I attached to the note with a custom event parameter. This has two problems: it's very CPU intensive, and it produces very volatile results. If I play a very high-pitched/high-speed note, it's going to get further past the cutoff point before the listener realizes and cuts it than a low-pitched/low-speed note moving very slowly. Even if they were the same static speed, the exact moment will be slightly different depending on when they were first played relative to the cycle of the listener.

This would be a huge help. Thanks.


  • EvilDragon
    EvilDragon Moderator Posts: 1,021 mod

    To be perfectly honest, I wouldn't hold my breath about this being implemented...

  • stephen24
    stephen24 Member Posts: 258 Advisor

    Can't imagine what you're up to that needs such accurate note release but here are some suggestions.

    1. Use wait(), dividing whatever value you use by the current speed. Assuming you're using tm pro controlling speed by cc, you would have to make a 128-element array of the speed setting for each cc value, reading them off from the display in the Source Module, and then in play using the cc value to select the required element. I've done something slightly similar to break into a long sample which may have been subject to speed changes. The read-off values are astonishingly accurate. (Won't work if you you change speed during the wait period).
    2. Make multiple copies of your sample, adjusting Sample End in each, and selecting the required copy by velocity or Group Start Options or whatever.
  • Reid115
    Reid115 Member Posts: 47 Member
    edited August 2022

    In my case, speed/tune can be modulated freely in realtime, so doing a calculation wouldn't work. The sample end also can't be relied upon for what I'm doing, for many reasons. For one, I specifically want the note to be "released" like note_off(), not cut off to silence. The end point also needs to be 1 millisecond in precision, which would mean 60k groups for just a 1 minute sample (and I'm already using multiple groups for different things anyways). Some of what I'm doing would still not even be possible if my request was actually implemented -- e.g., play a note until it reaches a certain point in the sample, then release the note X milliseconds later.

Back To Top