Start several loops on load



  • I have some loops that i want to play continuously, and start on load. I also want to be able to retrigger them with a button. I've tried a few things, and nothing is particularly reliable.
    In a sampler's onInit, I have

    //add button to UI. click to retrigger
    var PlayLoop= Content.addButton("Play Loops", 0, 10);
    PlayLoop.set("isMomentary", true);
    
    reg noteIds = [];
    
    var startnote = Synth.playNoteWithStartOffset(16, 48, 127, 0);
    noteIds[0] = startnote;
    Console.print("start loop 1 "+startnote);
    
    

    and I have onControl like:

    function onControl(number, value)
    {
        if(number == PlayLoop)
        {
                //turn off the auto start note first
                 Synth.noteOffByEventId(noteIds[0]);
                 Synth.playNoteWithStartOffset(16, 48, 127, 0);
             }
    }
    

    I get the console:

    Script Processor3: start loop 1 138
    Script Processor3:! onControl() - Line 7, column 35: NoteOn with ID138 wasn't found 
    

    I'm at a loss as to why the ID isn't found? Are onInit and onControl not part of the same scope or something weird? If that was the case, I'd think using noteIds in onControl would throw an error.



  • What do you think this does noteIds[0] = startnote; ?



  • @d-healey it puts the event ID of the note event into the first element of an array. I use that array to recall the value to turn that note event off. But it tells me that the ID doesn’t exist. Which is mysterious because I stored it successfully!



  • Ok, just wanted to check because this would make more sense to me

    reg noteIds = [];
    
    noteIds[0] = Synth.playNoteWithStartOffset(16, 48, 127, 0);
    

    Have you tried using the audio loop player?

    7118bfed-83c6-43ed-bf31-f00d6a7c0186-image.png



  • I did try that, but it also needs some sort of "impulse" (note-on) event to get it playing as far as I can tell. I was also getting really inconsistent results with the loop players actually starting playback from a note-on that was artificially generated in onInit(). Additionally, I was getting weird file loading problems when I tried to load a sample from the Project folder's Sample folder (it just showed {PROJECT PATH} (or whatever the environment variable is) in the top right of the Loop player.
    And even it was behaving, I would still need to track noteOns to re-trigger them, no? (Or perhaps not because they are monophonic, probably.)

    The crux of it is that it seems that I'm tracking events properly, and I should be able to generate note-off for those events, but it's not working. I'm using the "version 2" (shows 1.6 in "about" panel, tho) downloaded from the Hise.audio site, fwiw.




Log in to reply
 

14
Online

674
Users

2.7k
Topics

22.8k
Posts