Sampler Loop Start / End Point - change with sliders?



  • @Christoph-Hart I saw some code from a thread recently which looks like it could be used to control the Sampler Loop point from sliders - is this possible? I'm trying to link Sampler1.LoopEnd to a knob callback (unsuccessfully!). Loop on / off would be great as well. Here's the code below:

    /** Select all samples in the current samplemap
        ".*" is Regex and means everything.
    */
    const var allSamples = Sampler.createSelection(".*");
    
    /** You'll get an array of all samples, which you can iterate */
    for(s in allSamples)
    {
        /** Just multiply all sample properties with 2 */
        s.set(Sampler.LoopStart, parseInt(s.get(Sampler.LoopStart)) * 2);
        s.set(Sampler.LoopEnd, parseInt(s.get(Sampler.LoopEnd)) * 2);
        s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);
    }
    
    /** This needs to be called after a sample manipulation op
        in order to refresh the UI. */
    Sampler.refreshInterface();
    


  • @Christoph-Hart Whadayathink?!



  • It might work, although you need to be aware that changing the loop points will kill all voices and cause a streaming buffer refresh (because the loop point might intersect with the preload buffer range or other edge cases), so it's not something that you could automate as musical parameter.



  • @Christoph-Hart Ok that's encouraging...

    Any clues to how I'd write a callback would be very welcome 🙂



  • @DanH said in Sampler Loop Start / End Point - change with sliders?:

    s.set(Sampler.LoopStart, parseInt(s.get(Sampler.LoopStart)) * 2);
    s.set(Sampler.LoopEnd, parseInt(s.get(Sampler.LoopEnd)) * 2);
    s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);

    you probably want to think about what you are doing here:

        s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);
    

    essentially :
    "please set the end of the sample to 2 x the length of the sample"



  • 
    inline function onKnob1Control(component, value)
    {
        for(s in Sampler1.createSelection(".*"))
        {
            local l = parseInt(s.get(Sampler.SampleEnd));
            s.set(Sampler.LoopEnd, value * l);
        }
    };
    
    Content.getComponent("Knob1").setControlCallback(onKnob1Control);
    
    const var Sampler1 = Synth.getSampler("Sampler1");
    


  • This post is deleted!


  • @Christoph-Hart Thank you very much, there's no way in a million years I was going to get that lol!


Log in to reply
 

14
Online

1.2k
Users

3.8k
Topics

33.4k
Posts