Samplemap Prev/Next



  • Hi all,

    Im struggling to understand why my script(iteration) isn't fully working.
    Its not selecting Item/Array/var = 0.

    I have 5 items in an array(samplemaps) which are being displayed in a Viewport.
    I have Previous/Next buttons which go through the array, But the first item(0) is not getting selected. It skips index0. It goes 1,2,3,4.>Loop
    For the life of me! i cant figure out why!

    inline function onPrevBtnControl(component, value)
    {
        if(value == 1)
        {
            if(SML.getValue() == 1)
            {
                SML.setValue(formattedSMlength-1);
            }
            else
            {
                SML.setValue(SML.getValue()-1);
            }
            SML.changed();
        }
    };
    Content.getComponent("PrevBtn").setControlCallback(onPrevBtnControl);
    
    inline function onNextBtnControl(component, value)
    {
        if(value == 1)
        {
            if(SML.getValue() == formattedSMlength-1) //Samplemap length
            {
                SML.setValue(1);
            }
            else
            {
                SML.setValue(SML.getValue()+1);
            }
            SML.changed();
        }
    };
    Content.getComponent("NextBtn").setControlCallback(onNextBtnControl);
    

    formattedSMlength is the count of total items in the array.
    Where am i going wrong?!

    Thanks!



  • Post a minimal snippet that demonstrates the issue.



  • HiseSnippet 2992.3oc6ZstTaijEVBhRF6Mj4RM+X+yVUWtlZKSAArc.lYBapwXfLjZgDVLIyTEKKiPtscCxpUI0BhSpT07nrOB6iv9HMuA6d5t0kVxxFgARk8hYRMp69bqO8oO84qk12iZg88odZ5kNbnKVS+gFsG5v5uYeShi1K1RSurwodzK8wdqo0ZnqouOtilt9r+Heb8R2SS7629gVl1lNV3jtzzdCkXg2kLfvR5c+l+Yhs8yM6fOjLPg5UZ9BKpylTaZ.XKyZTSy0z5byd3WZxIaFCM86ucGBi50lYxv9Z52qEsyv18oW5Ho+MDexo1Xdi5ZsAAI694T6NbKl2q1l8I1c1OZN6qooarehGXVoG3qM1izgD2ehm3KDCfR3P0enOyjLu5plWshad5Jl28jl2WZz1xi3xRFgaa+NiW3vvdcMgk.UyRRq1LaV1XSJPgCaoAlmietGzHlipqUq1hnUqUa90mqL+ud1zSMsQs2aWzyPQ70Cy1jNvk5.MpVAFqBmbX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f0Rn9SJjZULx4CbaY0jui70Q7fh80Q.JXeSvknPYKRuXkK6QM9NdYPXpJeAzZ2YHG+Hru7tMC7rEyb0tifppOqJPU0MIwnTSr8bmPQ3Si54qaFCNMpquooJvzoxWTu39haHV1+i6jyY+e9SNmJT3eJtNOFH7eTM0B.t1PeF9gtwvqM3mWFAv1P+eA+RPXKOMMDisbvhbO.5yDdK.IgzWyq.3Fak++qB3+FuJ.8Y092kmuHJC
    

    Since im using subfolders for the samplemaps, ive put them in a zip. Place in Hise SampleMaps folder. Folder1.zip



  • @ten7kur Ok so first, you need to set your buttons to isMomentary and disable savedInPreset

    Then instead of giving you a working snippet, try to print the SML value in your buttons CB. You'll see that the viewport begins at 0, not 1...



  • @ustk said in Samplemap Prev/Next:

    @ten7kur Ok so first, you need to set your buttons to isMomentary and disable savedInPreset

    Then instead of giving you a working snippet, try to print the SML value in your buttons CB. You'll see that the viewport begins at 0, not 1...

    hm. Trying....
    Puzzled in terms of "print the SML value". Do you mean the Array thats populating SML?
    Would love to solve this on my own! but somethings not clicking for me..(knowledge wise)..



  • @ten7kur I just mean the value of the viewport Console.print(SML.getValue())
    You''ll see that a value of 1corresponds to the second item because a viewport is indexed from 0, not 1
    So0is the first item when you loop in your prev/next buttons, not1.



  • 😬 👍 👍
    Thanks!


Log in to reply
 

11
Online

650
Users

2.6k
Topics

21.5k
Posts