Sample switching with presets in Audio Loop Player



  • Hello how are you!

    I have been reading this forum for some months and it is a great knowledge niche about Hise in fact looking for I found all the answers to my doubts, but at this point I am somewhat lost ..,

    It turns out that I want to use an Audio Loop Player to mix with a Waveform generator and thus create different presets, I already tried to do it with a combo box through sample maps, in fact I can select sample maps very well in combo box but it does not load them in Audio Loop Player and the console sends me errors that I do not understand

    I annex the lines that I wrote in case someone can give me some advice 🙂

    Thanks in advance!

    //Audio Loop Player
    const var Sampler = Synth.getChildSynth("Sampler");
    
    //Sample maps array
    const var sampleMaps = Sampler.getSampleMapList();
    
    //Combo box
    const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
    cmbSampleMaps.set("items", sampleMaps.join("\n"));
    
    inline function oncmbSampleMapsControl(component, value)
    {
    	Console.print(value);
        Sampler.asSampler().loadSampleMap(sampleMpas[value-1]);
    };
    
    Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
    

    This is the error that the console throws me :{ ??? I think it's in Chinese heheh 🙂

    Interface:! function not found {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}
    : onInit() - Line 52, column 48 {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}

    Greetings and success!



  • @callybeat there is a misspelling here:

    Sampler.asSampler().loadSampleMap(sampleMpas[value-1]);
    


  • @ulrik Thank you very much friend! 🙂

    You know I already corrected the spelling mistake but it still did not work, in fact I noticed that Sample maps in the name of the folder is written with capital letters and I thought about changing that in the references but in the same way it did not work 😞 .. it still sends me the same error the console

    //Audio Loop Player
    const var Sampler = Synth.getChildSynth("Sampler");
    
    //Sample maps array
    const var SampleMaps = Sampler.getSampleMapList();
    
    //Combo box
    const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
    cmbSampleMaps.set("items", SampleMaps.join("\n"));
    
    inline function oncmbSampleMapsControl(component, value)
    {
    	Console.print(value);
        Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
    };
    
    Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
    

    Interface:! function not found {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}
    : onInit() - Line 52, column 48 {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}

    😅



  • @callybeat you made a reference to the Sampler using the "Create generic script reference" so the

    const var SampleMaps = Sampler.getSampleMapList();
    

    throws an error saying "function not found"
    So if you instead make a "Create typed Sampler script reference" this function exist and can be used.

    And when you have this reference to the Sampler you have to use

    Sampler.loadSampleMap(SampleMaps[value-1]);
    

    instead of

    Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
    

    Skärmavbild 2021-05-20 kl. 07.06.41.png

    Here's the changed code

    //Audio Loop Player
    const var Sampler = Synth.getSampler("Sampler");
    //Sample maps array
    const var SampleMaps = Sampler.getSampleMapList();
    
    //Combo box
    const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
    cmbSampleMaps.set("items", SampleMaps.join("\n"));
    
    inline function oncmbSampleMapsControl(component, value)
    {
    	Console.print(value);
        Sampler.loadSampleMap(SampleMaps[value-1]);
    };
    
    Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
    


  • @ulrik Friend thank you very much! 😎

    You are right the reference changes totally when selecting "Create typed Sampler script reference" although I see that it changes a bit since it is an Audio Loop Player

    this looks much better

    const var Sampler = Synth.getAudioSampleProcessor("Sampler");
    

    that this old reference

    const var Sampler = Synth.getChildSynth("Sampler");
    

    referencia.png

    I also change the custom logic
    this

    Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
    

    to this

    Sampler.loadSampleMap(SampleMaps[value-1]);
    

    and the result is this code

    //Audio Loop Player
    const var Sampler = Synth.getAudioSampleProcessor("Sampler");
    
    //Sample maps array
    const var SampleMaps = Sampler.getSampleMapList();
    
    //Combo box
    const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
    cmbSampleMaps.set("items", SampleMaps.join("\n"));
    
    inline function oncmbSampleMapsControl(component, value)
    {
    	    Sampler.loadSampleMap(SampleMaps[value-1]);
    };
    
    Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
    

    But I think luck is not with me since the console sends me an error 🙂 I think it is known that I am a beginner and it does not stop welcoming me lol 🤣

    Interface:! function not found {SW50ZXJmYWNlfHwxMjM5fDUyfDQ4}
    : onInit() - Line 52, column 48 {SW50ZXJmYWNlfHwxMjM5fDUyfDQ4}

    The only thing I'm sure of is that I'm doing something wrong lol 😂



  • @callybeat Aha, ok so your reference to "Sampler" is not a reference to a sampler actually, cause it's an "Audio Loop Player", then I understand why it's not working.
    You can not get a sampleMap list from an Audio Loop Player because it's not a sampler 🙂
    So this line is not working:

    const var SampleMaps = Sampler.getSampleMapList();
    

    because an ALP doesn't have a sample map.

    Can you describe what you want to do?

    Never mind, I see you want to load samples into the ALP using a combobox, right?



  • @ulrik I think you need to use this

    Engine.loadAudioFilesIntoPool();
    Sampler.setFile(String fileName)
    

    to load the audio file into the ALP
    so I would do something like this:

    store the audio files names in an array

    audioFiles = ["audio1.wav", "audio2.wav", "audio3.wav"];
    

    and point to this array in the cmb



  • @ulrik said in Sample switching with presets in Audio Loop Player:

    @ulrik I think you need to use this

    Engine.loadAudioFilesIntoPool();
    Sampler.setFile(String fileName)
    

    to load the audio file into the ALP
    so I would do something like this:

    store the audio files names in an array

    audioFiles = ["audio1.wav", "audio2.wav", "audio3.wav"];
    

    and point to this array in the cmb

    Do you have an example snippet for this?
    I am missing the connection here



  • @MikeB sorry, no snippet here, just looking at the documentation
    https://docs.hise.audio/scripting/scripting-api/audiosampleprocessor/index.html



  • @ulrik a thousand thanks 🤝 for the support thanks to you and @MikeB for the help, I think that with the example mikeB shared I almost finished my first project in Hise, thank you both are very helpful 😁



  • @callybeat I'm glad it worked out allright for you! 👍



  • I thought I would paste the solution of the theme here in case someone needs it ..
    😁

    // Load Audiofiles into pool ----------------------------------------------------------------------------------------------
    Engine.loadAudioFilesIntoPool();
    //--------------------------------------------------------------------------------------------------------
    
    
    
    // const vars----------------------------------------------------------------------------------------------
    const var AudioLoopPlayer = Synth.getChildSynth("Sampler");
    const var Random = Content.getComponent("Random");
    const var Knob62 = Content.getComponent("Knob62");
    const var Next = Content.getComponent("Next");
    const var Prev = Content.getComponent("Prev");
    //--------------------------------------------------------------------------------------------------------
    
    // Array Samples in AudioFiles-Folder----------------------------------------------------------------------
    const var inst = ["sample01.wav","sample02.wav","sample03.wav","sample04.wav","sample05.wav","sample06.wav","sample07.wav","CBsample2.wav"];
    //--------------------------------------------------------------------------------------------------------
    
    
    
    //Knob1 Sample selection---------------------------------------------------------------------------------
    inline function onKnob62Control(component, value)
    {
        Synth.getAudioSampleProcessor("Sampler").setFile("{PROJECT_FOLDER}"+inst[value]);
    };
    Content.getComponent("Knob62").setControlCallback(onKnob62Control);
    //--------------------------------------------------------------------------------------------------------
    
    // Random Button------------------------------------------------------------------------------------------
    Random.setControlCallback(onRandom_Control);
    
    inline function onRandom_Control(component, value)
    {    
        if (value)
        {
            Knob62.setValue((Math.randInt(0, 5)));
            Knob62.changed();
        }
    };
    //--------------------------------------------------------------------------------------------------------
    
    
    
    // Prev-Button----------------------------------------------------------------------------------------------
    inline function onPrevControl(component, value)
    {
        if (value)
        {
            Knob62.getValue() > Knob62.get("min") ? Knob62.setValue(Knob62.getValue() - 1) : Knob62.setValue(Knob62.get("max"));
    	    Knob62.changed();
        }
    };
    Content.getComponent("Prev").setControlCallback(onPrevControl);
    //--------------------------------------------------------------------------------------------------------
    
    
    
    // Next-Button ----------------------------------------------------------------------------------------------
    inline function onNextControl(component, value)
    {
        if (value)
        {
    	    Knob62.getValue() < Knob62.get("max") ? Knob62.setValue(Knob62.getValue() + 1) : Knob62.setValue(Knob62.get("min"));
    	    Knob62.changed();
        }
    };
    Content.getComponent("Next").setControlCallback(onNextControl);
    //--------------------------------------------------------------------------------------------------------
    

Log in to reply
 

10
Online

1.3k
Users

4.3k
Topics

38.5k
Posts