HISE Logo Forum
    • Categories
    • Register
    • Login

    Change VoiceLimit and VoiceAmount with a Button

    Scheduled Pinned Locked Moved Unsolved Scripting
    26 Posts 2 Posters 1.0k 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.
    • M
      meto396 @d.healey
      last edited by

      @d-healey when the button is 0 (off) then, else (1) all my buttons work like this the code works perferct when I use "const var Sampler1 = Synth.getChildSynth("Sampler1");" instead of "const var Sampler1 = Synth.getSampler( "Sampler1") ;" but then the CostumSampleImport doesn't work anymore

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

        @meto396

        @meto396 said in Change VoiceLimit and VoiceAmount with a Button:

        when the button is 0 (off) then, else (1)

        Break it right down. What does value = 0 mean. Or break it further down, what does = mean?

        = is the assignment operator, it means assign the value on the right side to the variable on the left side. So value = 0 means set value to 0. So if (value = 0) is the same as writing if (0) which will never fire because an if statement is always checking to see if the thing in the parenthesis is equal to 1.

        What you should be using is == which is a comparison operator.

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

        M 1 Reply Last reply Reply Quote 0
        • M
          meto396 @d.healey
          last edited by

          @d-healey I've used "==" already before but it still doesn't work

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

            @meto396 Did you remove the extra curly brace?

            Why did you change it to =?

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

            M 1 Reply Last reply Reply Quote 0
            • M
              meto396 @d.healey
              last edited by

              @d-healey yeah I removed it.

              I didn't remove it on purpose I've missed it when I wrote the code again

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

                Working here, however I noticed I had to get the reference to the sampler as a childSynth rather than as a Sampler.

                HiseSnippet 1187.3ocyW0saaaCElJ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gyPezLzGOC8qxoSBncwgpJC0SMlYJ5lK2TTv.8vfKaHYS5noFOgSwwGFhNMlqwkwCabIRIjxhLjcNufXiOWOpY8kqY7irf3K+wqEdCV4LL5RUYu1r6f1VfiBiOG16LDG6Ky3VbDRWNiGNlyndEaRfh9QiHBSrOWGBddCzily4EM5S7I3Hit7uuwaf2ggEE68eTwhG+6Qma95asSfqiZtmy+k71SZY1BWQVZoVQ9IGuq95xmzP21oKNcfaWH+BOOuksdTuiZy7+WPsOOVM9NaqmMrZzEdNfGwbA4ZpktIz0TzJ.4RXCzD+C7I8v5YaSUGVO6PjWlo.eK825WQaUhvTaSzu7yG1S6aVRGAO5PAIXi2SBJCvdB967R9+AJrtolCfRl9O4W1tqh1YN+sf.Xe0677JZpGn39qphGrpJd3pp3QqphGupJ9pUUwe3iqn54DmEK4AICSQnt8ZmT.Z0dZAXIz+J1D9yK
                

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

                M 1 Reply Last reply Reply Quote 0
                • M
                  meto396 @d.healey
                  last edited by

                  @d-healey that's what I said that it works as a childSynth but then the CostumSampleImport project doesn't work anymore

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

                    @meto396 Ah sorry I missed that. You have two choices, either have two references, one as a childSynth, one as a Sampler. Or with the childSynth reference use .asSampler() when you need to access the Sampler class functions.

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

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      meto396 @d.healey
                      last edited by

                      @d-healey said in Change VoiceLimit and VoiceAmount with a Button:

                      You have two choices, either have two references, one as a childSynth, one as a Sampler. Or with the childSynth reference use .asSampler() when you need to access the Sampler class functions.

                      but when I try to use both I get the "duplicate const var declaration" error or am I misunderstanding something?

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

                        @meto396

                        @meto396 said in Change VoiceLimit and VoiceAmount with a Button:

                        "duplicate const var declaration"

                        Variable names must be unique. - but I'd go with the asSampler method anyway.

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

                        M 1 Reply Last reply Reply Quote 0
                        • M
                          meto396 @d.healey
                          last edited by

                          @d-healey said in Change VoiceLimit and VoiceAmount with a Button:

                          asSampler

                          Does that mean I have to change everything in the CostumSampleImport script to asSampler if I reference the sampler as childSynth?

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

                            @meto396

                            Where you want to access a function that is part of the Sampler class (it shows up under the list of Sample functions in the API browser) you can use Sampler1.asSampler().myFunctionHere()

                            If you're doing this many times within an inline function you might just store the reference in a local variable to reduce the amount of code you have to write. local s = Sampler1.asSampler(); for example.

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

                            M 1 Reply Last reply Reply Quote 0
                            • M
                              meto396 @d.healey
                              last edited by

                              @d-healey like this?

                              const var Button1 = Content.getComponent("Button1");
                              
                              inline function onButton1Control(component, value)
                              {
                                  local s = Sampler1.asSampler();
                              
                                  if(value == 0)
                                  {
                                      s.setAttribute(s.VoiceLimit, 32);
                                      s.setAttribute(s.VoiceAmount, 32);
                                  }
                                  else
                                  {
                                      s.setAttribute(s.VoiceLimit, 256);
                                      s.setAttribute(s.VoiceAmount, 256);
                                  }
                              }
                              
                              Button1.setControlCallback(onButton1Control);
                              
                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @meto396
                                last edited by

                                @meto396 We've already established how to solve that problem, you need to get it as a childSynth not a Sampler.

                                It's the other places where you want it as a Sampler that you need to do that.

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

                                M 1 Reply Last reply Reply Quote 0
                                • M
                                  meto396 @d.healey
                                  last edited by

                                  @d-healey but when I use childsynth I get error after error because functions are not found

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

                                    @meto396 Check out the snippet I posted above.

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

                                    M 1 Reply Last reply Reply Quote 0
                                    • M
                                      meto396 @d.healey
                                      last edited by

                                      @d-healey I did already but this doesn't change my problems as soon as I change the getSampler to ChildSynth the whole code that works doesn't work anymore: screen1.png

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

                                        @meto396 said in Change VoiceLimit and VoiceAmount with a Button:

                                        the whole code that works doesn't work anymore

                                        That's because those other parts (the line numbers in the error messages) need the Sampler reference, so that's where you use .asSampler()

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

                                        M 1 Reply Last reply Reply Quote 0
                                        • M
                                          meto396 @d.healey
                                          last edited by

                                          @d-healey so all of them functions must be look like this?

                                          Sampler1.asSampler().clearSampleMap();
                                          
                                          d.healeyD 1 Reply Last reply Reply Quote 0
                                          • d.healeyD
                                            d.healey @meto396
                                            last edited by

                                            @meto396 Correct

                                            You can see in the API browser that function is part of the Sampler class

                                            7f65115e-337c-49c7-85e7-ef816fea4781-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
                                            • First post
                                              Last post

                                            46

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.2k

                                            Posts