Play note pressing a button...



  • I'm sure I'm not doing it right, but I can't really understand why I can't play a note hitting a button, with the following:

    Engine.loadAudioFilesIntoPool();
    
    //REFERENCES
    const var Kick = Synth.getChildSynth("Kick");
    
    const var Kick1_btn = Content.getComponent("Kick1_btn");
    const var Kick2_btn = Content.getComponent("Kick2_btn");
    
    
    
    //FUNCTIONS
    
    
    inline function onKick1_btnControl(component, value)
    {
    	Kick.playNote(24, 100);
    };
    
    Content.getComponent("Kick1_btn").setControlCallback(onKick1_btnControl);
    

    So I have a sampler, two samples loaded, super-simple, when I hit compile I get a "function not found" error for the playNote line.

    Thanks for your help 🙂



  • Synth.playNote() is the function you need. If it ever says function not found it means the thing you are trying to call the function on (in your case kick) doesn't have a function with that name. You can always use the auto complete popup (press ESC) to check what's available.



  • @d-healey Aaahh ok, and what if I had 2 samplers with different samples, how can I differentiate which sampler is going to play?



  • @alepan said in Play note pressing a button...:

    @d-healey Aaahh ok, and what if I had 2 samplers with different samples, how can I differentiate which sampler is going to play?

    at least 2 ways off the top of my head -

    1. put a midi processor in each sampler - that plays a note, and call each one
      or
    2. put a processor in each sampler that ignores all midi chanels except one(a different one for each sampler) and send them midi notes...


  • @Lindon Ok, thanks a lot!


Log in to reply
 

11
Online

672
Users

2.7k
Topics

22.7k
Posts