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

Half-pedal strategy

Discussion in 'Scripting Workshop' started by Dore Mark, Oct 4, 2021.

  1. Dore Mark

    Dore Mark New Member

    Messages:
    7
    I'm making a piano library, and was thinking about how to create a half damper script.

    One way of doing it is to use the fade_out command, I figured. On release, trigger a different fade out time. I know that this is not elegant, as I think the fade-out will not have a realistic decay curve (well, I want to try at least to see if it's better than nothing).

    Anyway, I think I need to disable the built in CC64 behavior first. How do I do that?

    Is there a better strategy? My library is fairly simple - just pedal up and pedal down sample groups - no fancy release triggers or release overtones. Just need the samples to fade (predictably) on release according to CC64 value. Seems using ADHSR would be much more complicated.
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    SET_CONDITION(NO_SYS_SCRIPT_PEDAL)
     
  3. Dore Mark

    Dore Mark New Member

    Messages:
    7
    Thanks! That worked - but now that I have a working test script, is there a way to get the fade out curve to be non-linear?
    It would be better as a curve similar to the release curve of ADHSR.
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Nope, it's always linear. You would need to emulate it by many small fadeouts that approximate an exponential curve...
     
  5. Dore Mark

    Dore Mark New Member

    Messages:
    7
    That really helps. I think I've worked out the math to get the decay curves emulated using small fadeouts.

    But now I'm wondering if there is an easy way to get samples to end when they fade to an inaudible level, rather than continue to decay exponentially until the sample file times out. Or would I have to make a timeout estimation before the fade starts and then cut off using that estimation?
     
  6. Dore Mark

    Dore Mark New Member

    Messages:
    7
    So I did emulate a exponential release curve delay by issuing fade_out commands with wait() in between.
    But I'm finding that the wait() command, because it delays execution of callbacks (?) can really mess with polyphonic playing. Sometimes the commands get ignored.

    EvilDragon Was this the method you suggested (?) using wait() in between fade_out() commands to simulate exponential decay?
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Yeah, so you could try using polyphonic variables in the note callback. They're practically necessary for stuff like this.
     
  8. Dore Mark

    Dore Mark New Member

    Messages:
    7
    Well, I almost have everything working. After making a script that controls the note-offs and fade-outs, the release triggers somehow don't work anymore.

    What commands are used to do release triggers in KSP?
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    play_note()

    And you will also want to use set_event_par_arr() to allow or disallow groups per event ID.
     
  10. Reid115

    Reid115 NI Product Owner

    Messages:
    40
    Curious about nonlinear fadeout curves as well... Maybe I'm misunderstanding the behavior of fade_out(), but wouldn't it be impossible to imitate the slope of the ADHSR release curve with small fadeouts? You can only add layers of fadeouts, not subtract, so you can only build release speed. The release curve ADHSR is the inverse of this, where it starts off fast and ends slow. Below is a crude drawing to explain. It almost makes me wonder what would happen if you ran fadeouts and fadeins at the same time. Could you use iterative calls to change_vol() to have more control?
    [​IMG]
     
    Last edited: Oct 26, 2021
  11. Dore Mark

    Dore Mark New Member

    Messages:
    7
    Basically, you break the fadeout curve into sections, where the first section is the fastest, etc. So it ends up being a series of fade_out(), wait(). You need to balance the fadeout time and the wait time, so that the curve is "discretized". I'm working on this after key release, but I do realize that if I were to crossfade in another sample I could probably have more control using the ADHSR controls. The main problem with the multiple fade outs is that the wait commands don't work well with polyphony, especially when triggering wait() with a CC.

    So today I used a change_vol() to immediately change the gain when a CC command is seen, and then trigger a fade out. Seems to work ok, but not the perfect solution as the change_vol is pretty abrupt.
     
  12. Reid115

    Reid115 NI Product Owner

    Messages:
    40
    Oh so does each new fadeout call completely replace the already running fadeout? I figured they would compound on each other.
     
  13. Dore Mark

    Dore Mark New Member

    Messages:
    7
    It does get cut off and replaced starting at the gain that the last one ended at.