HISE Logo Forum
    • Categories
    • Register
    • Login

    Audio Loop Player Script

    Scheduled Pinned Locked Moved Solved General Questions
    loopplayerscriptbutton
    8 Posts 3 Posters 684 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.
    • VorosMusicV
      VorosMusic
      last edited by

      Hi all you helping people out there.
      I've just started my second project in Hise and beeing more complex than the first, the first issue already appered.

      I would like to have a Loop of static noise, well ... looping for lack of a different word,.
      Activated with a button and NOT via midi.

      Any ideas and tipps, how I could script that?
      Thanks in advance!

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

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

        1 Reply Last reply Reply Quote 1
        • VorosMusicV
          VorosMusic
          last edited by

          Hmm...
          I set up a Switch/Button to change a few things as well as play a note, but the note is only getting played, when compiling. Everything else seems to get correctly triggered after the callback.

          inline function onSwitchControl(component, value)
          {
          	if(value)
          	{
          		Keys.set("visible", 1);
          		NoiseSlide.set("visible", 1);
          		KeyON.setBypassed("false");
          		KeyOFF.setBypassed("false");
          		Synth.playNote(6, 100);
          	}
          	else
          	{
          		Keys.set("visible", 0);
          		NoiseSlide.set("visible", 0);
          		KeyON.setBypassed("true");
          		KeyOFF.setBypassed("true");
          	}
          };
          
          Switch.setControlCallback(onSwitchControl);
          

          ...Any ideas, what I'm missing?

          ? 1 Reply Last reply Reply Quote 0
          • ?
            A Former User @VorosMusic
            last edited by

            @VorosMusic You're passing booleans as strings.

            inline function onSwitchControl(component, value)
            {
            	if(value)
            	{
            		KeyON.setBypassed(false); //No quotation marks
            		KeyOFF.setBypassed(false);
            		Synth.playNote(6, 100);
            	}
            	else
            	{
            		KeyON.setBypassed(true);
            		KeyOFF.setBypassed(true);
            	}
            
            	//you can also move these out here:
            
            	Keys.set("visible", value);
            	NoiseSlide.set("visible", value);
            };
            

            Or if you want to be even more efficient:

            //Since you're using a switch, you can treat *value* like a boolean.
            
            /*
            The 1-value trick inverts the boolean of the switch. 
            Which means when the switch is active (1), 
            setBypassed is false (0) & vice-versa.
            */
            
            inline function onSwitchControl(component, value)
            {
            	KeyON.setBypassed(1-value);
            	KeyOFF.setBypassed(1-value);
            	Keys.set("visible", value);
            	NoiseSlide.set("visible", value);
            
            	if (value)
            	    Synth.playNote(6, 100);
            };
            
            VorosMusicV 2 Replies Last reply Reply Quote 0
            • VorosMusicV
              VorosMusic @A Former User
              last edited by

              @iamlamprey Oh cool.
              I didn't know I could treat the switch value as a boolean.
              Thanks for the trick.

              And I try if rewriting that fixes my issue!

              1 Reply Last reply Reply Quote 0
              • VorosMusicV
                VorosMusic @A Former User
                last edited by

                @iamlamprey
                The code is a lot cleaner now, but still the same problem.

                On its own:

                • playing the note works
                • switching visibility works

                Together, everything works as expected, except the note is not playing...
                :face_with_raised_eyebrow:

                ? 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @VorosMusic
                  last edited by A Former User

                  @VorosMusic So to clarify:

                  INSIDE HISE
                  Everything works properly.

                  IN COMPILED PLUGIN/EXE
                  Hiding/showing elements works, but no audio from playNote() method?

                  If that's the case, it suggests either the Loop Player can't find the audio file (https://docs.hise.audio/working-with-hise/settings/project.html#embed-audio-files), or the Bypass of the Loop Player is inverted or not working correctly.

                  VorosMusicV 1 Reply Last reply Reply Quote 0
                  • VorosMusicV
                    VorosMusic @A Former User
                    last edited by

                    @iamlamprey Thank you for your help!
                    I don't know why. I redid some other elements of my code and suddenly it worked.
                    So yes for now its working properly in Hise itself.

                    1 Reply Last reply Reply Quote 0
                    • VorosMusicV VorosMusic marked this topic as a question on
                    • VorosMusicV VorosMusic has marked this topic as solved on
                    • First post
                      Last post

                    32

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.7k

                    Posts