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

Solved fade_in, fade_out

Discussion in 'Scripting Workshop' started by mindblower23!, Sep 27, 2021.

  1. mindblower23!

    mindblower23! NI Product Owner

    Messages:
    40
    I can't get my head around it:

    Code:
    active_event_id := play_note( $EVENT_NOTE, $EVENT_VELOCITY, 0, 0 )
    fade_in(active_event_id, 500000)
    fade_out(active_event_id, 1000000, 0)
    How is fade_out meant to be used? It overwrites fade_in and always starts the fade_out at the beginning of the sample ...

    Or to put it another way: How else can I have a fade in at the start and a fade out at the end of a sample? And I want to change it at runtime. Is having a group for each sample and controlling the group volume envelope the only way?
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    It's better done with envelopes, yeah...
     
  3. mindblower23!

    mindblower23! NI Product Owner

    Messages:
    40
    Ok, thanks! And there is no way to do it with zone envelopes in any way? Do I have script access to them?
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    No script access to zone envelopes. However you can actually change the AHDSR parameters before you play a note via KSP. That would work.
     
  5. mindblower23!

    mindblower23! NI Product Owner

    Messages:
    40
    You mean by doing something like

    set_engine_par(ENGINE_PAR_DECAY, some_value, 0, find_mod(0, "ENV_AHDSR"), -1)

    But would that work if multiply notes in the same group are played at the same time?
     
  6. mindblower23!

    mindblower23! NI Product Owner

    Messages:
    40
    This is what I'm currently working on. Maybe that makes it clearer what I'm trying to accomplish ...

    Screenshot 2021-09-28 at 01.01.21.png

    fade_in and fade_out would have been perfect if only they worked the way I thought they do ;-)
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    They work just fine, but you need to add wait() in between them if you want to do that. However I still think it's better to do this with an envelope.
     
    • Like Like x 1
  8. mindblower23!

    mindblower23! NI Product Owner

    Messages:
    40
    Just to finish this up: I now use a group for each sample/zone with a group volume envelope where I use attack, hold and decay to create the fades. Works like a charm. Thanks again ED for showing me the way! :)