HISE Logo Forum
    • Categories
    • Register
    • Login

    Custom Curve for Synth.addVolumeFade() ?

    Scheduled Pinned Locked Moved General Questions
    12 Posts 4 Posters 707 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk @civet
      last edited by

      @civet Why don't you simply use a table envelope?

      Screenshot 2022-05-26 at 12.39.47.png

      Can't help pressing F5 in the forum...

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @ustk
        last edited by

        @ustk That's no good if you want to crossfade between two notes.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        ustkU C 2 Replies Last reply Reply Quote 2
        • ustkU
          ustk @d.healey
          last edited by

          @d-healey Ok, I haven't understood this was the intention...

          Can't help pressing F5 in the forum...

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @ustk
            last edited by

            @ustk I didn't look at the snippet so I have no idea. But if he is wanting to xfade two notes then the envelope might not be the best way.

            Back in the days when HISE was young I asked for this same feature:
            https://forum.hise.audio/topic/41/crossfading-notes/
            https://forum.hise.audio/topic/28/some-basic-questions/

            And I see this from one of those threads in 2016! :p

            @Christoph-Hart

            But I can add fade types to the new fade event type, sure...

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • C
              civet @d.healey
              last edited by civet

              @d-healey said

              @ustk That's no good if you want to crossfade between two notes.

              That‘s it!

              1 Reply Last reply Reply Quote 0
              • C
                civet
                last edited by civet

                Envelopes are not suitable for all situations, even dynamically change their values, because Envelope affects the entire sampler.

                Synth.addVolumeFade() can more precisely control the gain of voices associated with given midi event, without touching the value of Attack or Release.

                But now Synth.addVolumeFade() can only use a hardcoded linear fading. It would be nice if we could bind it to a Table or any other custom function.

                something like this:

                Synth.addVolumeFadeWithFunction(eventId, fadeTime,  customFadingFunc);
                
                inline function customFadingFunc(t)
                {
                    return Table1.getTableValue(t);
                }
                
                Christoph HartC 1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart @civet
                  last edited by

                  I'm currently busy with other stuff, but maybe something like this could be added at some point:

                  const var FadeHandler = Engine.createFadeHandler();
                  
                  // the event ID can be used to distinguish events
                  // the normTime is from 0...1 and you need to return
                  // a value between 0...1 (pitch values will be converted
                  // automatically
                  inline function fadeIn(eventId, normTime)
                  {
                      return normTime;
                  };
                  
                  inline function fadeOut(eventId, normTime)
                  {
                      return 1.0 - normTime;
                  }
                  
                  // Register custom callbacks
                  FadeHandler.setCustomVolumeFadeCallbacks(fadeIn, fadeOut);
                  FadeHandler.setCustomPitchFadeCallbacks(fadeIn, fadeOut);
                  
                  // Or choose a predefined fade type
                  FadeHandler.setVolumeFadeType(FadeHandler.Logarithmic);
                  FadeHandler.setVolumeFadeType(FadeHandler.Linear);
                  
                  const var s = Synth.getChildSynth("MySampler");
                  
                  // Register the fade handler to a specific sound generator
                  FadeHandler.registerTo(s);
                  
                  // Register the fade handler to all sound generators
                  FadeHandler.registerAsGlobalFadeHandler();
                  

                  However for performance reasons these fade functions will only be called once per block and then ramped between so if you have ultra fast fades, it might get washed out a bit (the inbuilt types like linear and logarithmic and whatever else I come up with might not have this limitation). Also I need to make sure that there is absolutely no overhead if you don't use this feature.

                  C d.healeyD 2 Replies Last reply Reply Quote 2
                  • C
                    civet @Christoph Hart
                    last edited by

                    @Christoph-Hart Thanks!

                    Would it be possible to just link to a Table then convert a Table to an interpolation algorithm internally?

                    Christoph HartC 1 Reply Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart @civet
                      last edited by

                      @civet You mean something like

                      const var t = Engine.createAndRegisterTableData(0);
                      
                      FadeHandler.setVolumeFadeType(FadeHandler.Table, t);
                      

                      Yes that's a good idea. I could also add a

                      FadeHandler.setHighResolutionMode(true);
                      

                      to control whether to calculate one ramped value per block or one per sample (when you supply a custom callback, it will always use the low resolution mode).

                      1 Reply Last reply Reply Quote 1
                      • d.healeyD
                        d.healey @Christoph Hart
                        last edited by

                        @Christoph-Hart said in Custom Curve for Synth.addVolumeFade() ?:

                        (the inbuilt types like linear and logarithmic and whatever else I come up with might not have this limitation).

                        Rather than having in-built types I think it would be nice to have it work similar to the loop crossfade function you added. So you'd only need a single function with a parameter to set the curve amount.

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey
                          last edited by

                          Bump Bump :)

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          19

                          Online

                          1.7k

                          Users

                          11.8k

                          Topics

                          102.5k

                          Posts