Custom Curve for Synth.addVolumeFade() ?
-
@ustk That's no good if you want to crossfade between two notes.
-
@d-healey Ok, I haven't understood this was the intention...
-
@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
But I can add fade types to the new fade event type, sure...
-
-
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); }
-
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.
-
@Christoph-Hart Thanks!
Would it be possible to just link to a Table then convert a Table to an interpolation algorithm internally?
-
@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).
-
@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.
-
Bump Bump :)