How to cross fade between samplers with a knob control



  • I have two samplers, one containing a deck of close miced stuff, and the other containing another deck with the second mic that was placed further away. I would like to make a knob control, that when on 0.00 is 100% sampler 1, and when on 1.00 is 100% sampler 2. So a Mic Distance knob if you will, that is actually a cross fader between samplers.
    Could anybody give me some clues on how to do this in HISE? Great product by the way, really love it so far!



  • Is there a reason you've chosen to put the two mic positions in separate samples instead of combining them in a single sampler - http://forum.hise.audio/topic/75/multimic-samples

    If you combine them my general purpose mix mixer script will be a good starting point - http://forum.hise.audio/topic/312/general-purpose-microphone-mixer

    If you still want to keep them separate then you just need to link a knob to the gain parameter of each sampler. Or you could add a constant modulator to the gain section of each sampler and link your knob to that. Basically there are many ways to do this.



  • Yup, I'd definitely recommend using multi mic samples too. But using constant modulators will not work, because mic positions get the same modulation signal.

    This is an example that fades between a sine wave and a noise generator. I also added a table that you can use to specify the crossfade curve - depending on the coherence of your mic signals, it might need some adjustment to make a smooth transition:

    HiseSnippet 1527.3oc6YE2aSaDE2NIFnoTDLwj1er+vJZSJcqzZmx.1PSskzFTAZaTSWAzzD6h8kjSXeW14yEJHj1Gs8QXeD1GA9Fr8ty1w1sl1jx1XkkH0Heu28dueu28t26E21blCNHfw0zmcuCGh0zurQmCohAMGfHTsMWWS+JFagBDXtYDo6c3PTP.1USWu78kDzmohl5yaW4dHOD0AmRRSaeFwA+HhOQjRs8pOj340B4h2i3mY22b0McXzlLOVHfmxFVZCQNOG0GuMRtsRFZGPvuHPS2xX4FKxetc2Ws1hG4ygOd.7c+7z0bB4bLUrOHtltg9eBezM1vkHX7NBj.C5z3dL2C6Lf8BZjo2mDP55gkKr05.XJh7lTHTzC4fyr0VLOWY.Q9rVyADO21Ig0.MM8KzNMHWNJHecisHtjQzSC1WUwvLUhrga8R4gbkbP19cA4SAd5YfWkH3cMiNNbxPQJGI1l0XjymCVQ6UqzRFFMYvNnhE8QOG2hCKFIQ8aYYsfYCKq4uaU3PNPXd.BRo3rffdxDAD.byu2LQAHWWEo50xukZKXZaI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0mYDAWS4ESyONpuW9in56mweR6EG8ZMTY+2O80Zjc5x2Uo8e8BetwusN1CkK.9X4OULkvSWsfh+GsL4YOAtxXmInFG9bSl6mXnBrmm.r5f+7CfupQaz+ERH1kEJHz9agfFGuDlse6P+NvbNvuKb.hRgeZqbd+RxYUhVaIWGMnC00J4M1EyzVtVOlocBy+UrQlv9khB6WzXaFIHoWp54OTyKNctroykMctroykcNetrKaj9x6lNU1zoxlNU1+6lJqzIYixmlMloPaT48xOhY1HqjMNBykyJ4xiPmOxgydlSz6lVV33RJJvoBU8e0dFisjqMsSdizxSNeXzom43HKLeC3rqXIZLwRr7DKwMmXI9lIVhaMwRb6IVh6bBRHmScsPAyO51nl1egYP4fN
    

    If you want to adjust it for your setup, just put the two SimpleGain effects in the Sampler and set it's routing matrixes accordingly.



  • Hi, thanks all for the information. I have now used the multimic system. It works fine 🙂
    Two more auestions. The code for crossfading is now this:

    function onControl(number, value)
    {
    switch(number)
    {
    case micDistance:
    gainFx[0].setAttribute(0, 0 - value);
    gainFx[1].setAttribute(0, -100 + value);
    break;
    }
    }
    Where the knob value goes from -100 to 0. This linear gaining howver, results in them both being -50 when the knob is in the middle and is almost silent. Is there a math formule I could use to exponentially decrease or increase the gain? Sorry if this is a newbie question, I was never really good at math (but have been a software developer for almost 15 years now).

    To compile a vst, I can't seem to download Visual Studio Community 2015 (Needed to log in using my microsoft account to download the older 2015, but when I get to the download page for the legacy products, no items are shown). I am able to download the 2017 Community edition. Will it work with that version?

    Again, awesome work. Really love HISE!



  • The problem is that you are using the decibel scale in a linear fashion and -50dB is basically silence. Instead, you need to use the gain factor, which is a value from 0 to 1 (1 is unity gain, and 0.5 is -6dB). The example I posted above uses this scale (there are functions in HISE to convert from decibel values to gain factor and vice versa).

    But even with the gain factor, a crossfade without volume changes is only possible for coherent signals, which are practically non-existent - even the same recording with other mic positions has different phases. For all other signal types, you'll need to apply an equal power crossfade - that is why I added the table so you can adjust the curve to the shapes known from your DAW crossfades 🙂

    Take a look again at the example code, it's all in there. Obviously you need a slider with a range from 0 to 1 instead of -100 to 0 (the mode NormalisedPercentage will do that for you).

    local gainValue2 = CrossfadeTable.getTableValue((1.0 - value) * 127);
    local gainValue1 = CrossfadeTable.getTableValue(value * 127.0);
    	
    local dbValue2 = Engine.getDecibelsForGainFactor(gainValue2);
    local dbValue1 = Engine.getDecibelsForGainFactor(gainValue1);
    	
    CloseMicGain.setAttribute(CloseMicGain.Gain, dbValue1);
    FarMicGain.setAttribute(FarMicGain.Gain, dbValue2);
    


  • Thank you for your help. I'm currently busy with a commercial project, but will return to the project soon.


Log in to reply
 

4
Online

517
Users

1.9k
Topics

14.5k
Posts