Custom Curve for Synth.addVolumeFade() ?
-
Can we use a custom interpolation in addVolumeFade() ?
I tried to implement it with timer and table, but maybe it's not a good practice. Do you have any good suggestions?
HiseSnippet 1139.3oc4W0saaaCElx1pnxcsXsnXXWpUrAXu0jY0l0Nirg5DG6BiUmXD6lscUAqDsMQjH0nnbmwPe+1k6QouAaGRJaKmnk5401K17EB4b34P9c96iLCDbeRRBWfrbFMOlfr9H6gyYxosmhoLTuiPV2xtONQRDtFUGNOFmjPBPVVkepRgkSEj92adxg3PLymrREBcFm5SdFMhJWocPqefFF1EGPFQixY8ds54yYs4g7T.Oksafhw9mimPNFqLqjMx5ZcBnRtXnDKIIHqJGxClObJ+ULi8mQSnuLjnD7PCgMxntKOLPgX0eiZOkFFLXQbmfPV1CVkEJaxB20tOMftT+prwGqWvckG4yGVkVGdkWCdd4gWibvq.HYkCRULP511C8EzX4pUT34F18XPwYLFR64ghwVToOqjcaNXAStaD9bRWAHrziZOpQi66Bepue0pBxDWedJS598tM12HlJDfmclAe5E.52wCLDpQIR2YXgqDCQiGnewQLgHayih4LPn18FoW9d02ebJyWR4LWN6XtjbBqV8p+VUmKs88g3BJ2psISYM.YNKPkWC.WN51ycSjXgT09Hp0X2FdfYutp6EOmwiMGzEVSgVAOLD7snkM6pAg5SdG3ngClNtlQ96fDT8pNv5N4RXNKQFONaK.kutpSH2GGB4qvTBXoImoBQc54Lk5Zt0fXycGS9u9WqDpuLTwAAmwCSiHpIlZqmztuKT.Ma8W51rIrEMadobQV7VikF8RhHy9kQNzfsdW60966ZyOT4ap44Ljy5wnxShIYxqF67JnGGk0zn51yPH.EotW+lY855TDhB6w0sMcSHM3yyvDfkXj0WX+f81c4uG2F9L6D3y3uRI2zHiPOu2QJyyNR3zADESDRpJvsNhLCXqLiaN1GQRNGpkZay5ogjyaEf+5Jv8yslmW3Uz.4Tftw52AwoD5joRkTflS7Ry6.SCOHMDKWm9Qw4ls.TcWalWMWyRnx444juHmTkMiS5sT61P3da6ATo+zhwaoBvKTYdei2LF9aZ2Y7XhubEXqX28mtR5724P4VFnbC6gTFQOrqAxmnkc+Q7Lh6SILhPkT8thad+iM8l23M9l2S7kvwORfYIw7j013gjH5HXbHIuxmm.2sP9kSUU475aywhBW5MOoKDjE5yPrLUnaWNHRQHtV6Q4MtljmrZ8olb1WvcuUde8bfOnid+6YJd275EmEXbHMJNjzgMiDBTtZLdGficLNMTtP65M484Ld7TNi5muC3ThTPmLgHxi8BCnCjR38iqzb2VmRBI37cyedqmAcgXAjmHaYtv6e7K4Jrd8o1F35plLc+uACe4+exveJOURYS5igFU30.1GmFMDHV8I.RXLRXh5V+RJxQibCkrgYkEnE9S3W1hdJYqrE8Vr3GjyHB6K3uv271LUu700Zf3lo+Gxbf+yPP1c4ixrsg2hih.FwW36qR26.4mh84AagOObK7YusvmuYK74QagOOdK74auReTWFcPpjGYFEAEC5nevqkUGl54o5tdzek7O8rG
-
@civet Why don't you simply use a table envelope?
-
@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 :)