2 Sets of Sample Maps?



  • I have two samplers, each with their own combo box, with which you can select sample maps.

    But I'd like a different selection for each combo box.

    It seems like there's only one list of sample maps - Sampler.getSampleMapList();

    Can I script a way to divide the list? Is there a way of having two separate lists?

    Thanks!



  • @DanH - get your list of sample and divide them out into 2 arrays - load each combo box with one of the arrays...





  • @Lindon I'm definitely missing a piece of the puzzle here 😆

    Feels like I need a separate .getSampleMapList()

    const var sampleMaps = Sampler.getSampleMapList();
    const var SAMPLEBOX = Content.getComponent("SAMPLEBOX");
    const var SAMPLEBOX1 = Content.getComponent("SAMPLEBOX1");
    const var mySampleMapNames = ["KICK 01", "KICK 02", "KICK 03", "KICK 04", "KICK 05"];
    const var mySampleMapNames2 = ["SNARES", "KICKS"];
    
    SAMPLEBOX.set("items", mySampleMapNames.join("\n"));
    SAMPLEBOX1.set("items", mySampleMapNames2.join("\n"));
    
    inline function onSAMPLEBOXControl(component, value)
    {
      Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
    };
    
    Content.getComponent("SAMPLEBOX").setControlCallback(onSAMPLEBOXControl);
    
    inline function onSAMPLEBOX1Control(component, value)
    {
      Sampler2.asSampler().loadSampleMap(sampleMaps[value-1]);
    };
    
    Content.getComponent("SAMPLEBOX1").setControlCallback(onSAMPLEBOX1Control);
    


  • Forget about the .getSampleMapsList() function for a minute. You're over complicating it. You have an array that you want to split in two.

    So, make an array with 10 values

    const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    Now split it into two arrays using a loop

    const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    
    const a1 = [];
    const a2 = [];
    
    for (i = 0; i < 5; i++)
    {
        a1[i] = a[i];
        a2[i] = a[i + 5];
    }
    
    Console.print(trace(a1));
    Console.print(trace(a2));
    

    Now adapt this to suit your use case.



  • @d-healey Ok I'm lost now!

    Where do I put the new arrays?



  • @DanH Wherever you want them... or you can just populate the combobox lists directly from the initial array, one item at a time, in the loop.



  • @d-healey I don't understand - the arrays aren't related to the sample maps in any way - I was expecting to do something like below but the function doesn't work like that...

    inline function onSAMPLEBOXControl(component, value)
    {
      Sampler1.asSampler().loadSampleMap(sampleMaps[a1]);
    };
    
    Content.getComponent("SAMPLEBOX").setControlCallback(onSAMPLEBOXControl);
    


  • @DanH Show me how you're doing it currently with a single array



  • @d-healey

    inline function onSAMPLEBOX1Control(component, value)
    {
      TRANSIENT.asSampler().loadSampleMap(sampleMaps[value-1]);
    };
    
    Content.getComponent("SAMPLEBOX1").setControlCallback(onSAMPLEBOX1Control);
    


  • Right, your array is called sampleMaps and this contains all of the sample maps.

    You want to split this into two arrays, one for each combobox (there are other ways but this will be the simplest). Your code will look exactly the same except the name of the array will be different in each combobox's callback.



  • @DanH said in 2 Sets of Sample Maps?:

    @d-healey

    inline function onSAMPLEBOX1Control(component, value)
    {
      TRANSIENT.asSampler().loadSampleMap(sampleMaps[value-1]);
    };
    
    Content.getComponent("SAMPLEBOX1").setControlCallback(onSAMPLEBOX1Control);
    

    OK so where are you loading up "sampleMaps" ??

    -- and maybe think about naming things better...

    const var mySampleMaps = ["mapName1","mapName1","mapName2","mapName3","mapName4","mapName5","mapName6"];
    
    inline function onSAMPLEBOX1Control(component, value)
    {
      TRANSIENT.asSampler().loadSampleMap(mySampleMaps[value-1]);
    };
    
    Content.getComponent("SAMPLEBOX1").setControlCallback(onSAMPLEBOX1Control);
    

    can you work i tout from there?



  • @Lindon @d-healey I think I've got confused with the .getSampleMapsList() function and I've been thinking that's the only way to get the samplemaps into the sampler. I see now it's more of a convenient way to get the whole list in one go.

    I think I've got it now, thanks both 👍



  • @DanH That function just provides an array of sample maps names. If you know the names aren't going to change you can write it out manually like Lindon demonstrated.



  • @d-healey Thanks, I wrote out all 320 in my last project into one array (in order to change the names) 😂

    So to clarify something - when I had a list of sample maps and I deleted say one, the whole list after that one obviously shifted one map - and my presets which used the maps after that one were loading the wrong maps (i.e they loaded the map 1 below what I had saved).

    Am I going about this the wrong way? Should the sampler be able to find the correct sample map no matter how they are arranged in the samplemaps folder?



  • @DanH

    Should the sampler be able to find the correct sample map no matter how they are arranged in the samplemaps folder?

    The sampler doesn't do any finding. All it does is load the sample map you tell it to, it's your job to implement the mechanism for that.

    If you are loading sample maps from a UI control and that UI control is saved in the preset, then when you delete or add a sample map it could definitely screw things up and I think there's not much you can do about it.



  • @d-healey Ok I think my assumption was right then, thanks.


Log in to reply
 

10
Online

1.3k
Users

4.2k
Topics

38.3k
Posts