HISE Logo Forum
    • Categories
    • Register
    • Login

    Start several loops on load

    Scheduled Pinned Locked Moved Scripting
    6 Posts 2 Posters 406 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pnyboer
      last edited by

      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.

      http://sensel.com/morph

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

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

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        P 1 Reply Last reply Reply Quote 0
        • P
          pnyboer @d.healey
          last edited by

          @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!

          http://sensel.com/morph

          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by

            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

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • P
              pnyboer
              last edited by

              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.

              http://sensel.com/morph

              1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey
                last edited by

                Use this version - https://github.com/davidhealey/HISE/tree/develop

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                24

                Online

                1.7k

                Users

                11.8k

                Topics

                102.5k

                Posts