HISE Logo Forum
    • Categories
    • Register
    • Login

    Change panorama position of a noteOn Message

    Scheduled Pinned Locked Moved Feature Requests
    25 Posts 5 Posters 1.3k 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.
    • ulrikU
      ulrik @Frankbeat
      last edited by

      @Frankbeat if you are using a sampler, you can do this but it's not recommended to do it in the NoteOn callback, but you could make a function to spread the pan for each sample in the sampler and save this in the sample map.
      Or you could connect the function to a "spread" knob and set it but not while playing.

      I use this script for one of my sampled instruments, it's only 16 notes and each note has it's own pan knob, but you could modify this script to your likings of course

      //  Pan --------------------------------------
      inline function onPanKnbsControl(component, value)
      {
          //  Selects all samples
          Sampler1.selectSounds("");
      
          //  get number of samples selected
          local NUMSelected = Sampler1.getNumSelectedSounds();
          
          // lookup array (note numbers)
          local indexList = ["48", "50", "52", "53", "55", "57", "59",
          "60", "62", "64", "65", "67", "69", "71", "72"];
          
          for (i = 0; i < NUMSelected; i++)
          {
              local index = PanKnbs.indexOf(component);
              local root = Sampler1.getSoundProperty(Sampler1.Root, i);
              Console.print(root);
                      
              if (root == indexList[index])
              {
                  Sampler1.setSoundProperty(i, Sampler1.Pan, PanKnbs[index].getValue());
              }
          }
      }
      
      for (p in PanKnbs)
      {
          p.setControlCallback(onPanKnbsControl);
      }
      

      Hise Develop branch
      MacOs 15.3.1, Xcode 16.2
      http://musikboden.se

      FrankbeatF 1 Reply Last reply Reply Quote 1
      • FrankbeatF
        Frankbeat @ulrik
        last edited by

        @ulrik Wow… thank you! I will have to investigate this but no, I'm not dependent on using the onNoteOn callback for making it happen… Only purpose is to be able to set the stereo width across the keyboard. So, your example reads very promising on first glance. I'll report!

        Using HISE from the develop branch (Feb '23)

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

          @Lindon said in Change panorama position of a noteOn Message:

          @d-healey said in Change panorama position of a noteOn Message:

          Link Preview Image
          Change specific samples "pan"

          Is there a way to set a specific samples "pan", in the sampler, via scripting? like the way you can do with the gain Message.setGain()

          favicon

          Forum (forum.hise.audio)

          yeah thats about modulating the output of the sampler with a random value - this thread seems to me to be more about assigning specific notes to specific positions...unless I'm misunderstanding this.

          If I remember correctly you can use a simple gain module and change the balance knob per note.

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

          1 Reply Last reply Reply Quote 0
          • ulrikU
            ulrik @Frankbeat
            last edited by ulrik

            @Frankbeat I would do it something like this

            Pan/Note Test

            Hise Develop branch
            MacOs 15.3.1, Xcode 16.2
            http://musikboden.se

            FrankbeatF 1 Reply Last reply Reply Quote 1
            • FrankbeatF
              Frankbeat @ulrik
              last edited by

              @ulrik said in Change panorama position of a noteOn Message:

              @Frankbeat I would do it something like this

              Pan/Note Test

              Thank you very much!
              What is that Timer Object for? Is it a workaround to omit a call from onNoteOn?

              Using HISE from the develop branch (Feb '23)

              Christoph HartC ulrikU 2 Replies Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart @Frankbeat
                last edited by

                You need a stereo fx with a scripted voice start modulator.

                1 Reply Last reply Reply Quote 1
                • ulrikU
                  ulrik @Frankbeat
                  last edited by

                  @Frankbeat you don't need the timer, it's just there for the visual meters in this example.

                  Hise Develop branch
                  MacOs 15.3.1, Xcode 16.2
                  http://musikboden.se

                  FrankbeatF 1 Reply Last reply Reply Quote 1
                  • FrankbeatF
                    Frankbeat @ulrik
                    last edited by Frankbeat

                    @ulrik If I want to apply the same panorama settings to a Sampler2, would this be a more complex operation?
                    I have tried to just duplicate the setSoundProperty call like:

                    	    Sampler1.setSoundProperty(i, Sampler1.Pan, pan);
                    	    Sampler2.setSoundProperty(i, Sampler2.Pan, pan);
                    
                    

                    But that doesn't work. It makes the knob have no effect anymore.

                    Using HISE from the develop branch (Feb '23)

                    ulrikU 1 Reply Last reply Reply Quote 0
                    • ulrikU
                      ulrik @Frankbeat
                      last edited by

                      @Frankbeat with the same knob?
                      Can I see your code?

                      Hise Develop branch
                      MacOs 15.3.1, Xcode 16.2
                      http://musikboden.se

                      FrankbeatF 1 Reply Last reply Reply Quote 0
                      • FrankbeatF
                        Frankbeat @ulrik
                        last edited by Frankbeat

                        @ulrik Yes, both with the same knob. Here is the function (script references for Sampler1 and Sampler2 are given, but not shown here):

                        const spreadKnb=Content.getComponent('spread');
                        inline function onSpreadKnb(component, value) {
                        	Sampler1.selectSounds('');
                        	local NumSelected = Sampler1.getNumSelectedSounds();
                        	local sampleRoots = [];
                        	for (r = 0; r < NumSelected; r++) sampleRoots.push(Sampler1.getSoundProperty(Sampler1.Root, r));
                        	sampleRoots.sort();
                        
                        	local lowestNote = sampleRoots[0];
                        	local highestNote = sampleRoots[sampleRoots.length - 1];
                        	
                        	local range = highestNote - lowestNote;
                        	local centerNote = lowestNote + range/2;
                        	
                        	local step = 150 / range;
                        	
                        //	Note numbers of both maps are:
                        //	45,46,47,48,49,50,51,   52,   53,54,55,56,57,58,59];
                        	
                        	//	Spread from the center and out
                        	for (i = 0; i < 59; i++) {
                        	    pan = (-(52-sampleRoots[i])) * value;
                        	    Sampler1.setSoundProperty(i, Sampler1.Pan, pan);
                        	    Sampler2.setSoundProperty(i, Sampler2.Pan, pan);
                        	}
                        };	spreadKnb.setControlCallback(onSpreadKnb);
                        

                        Using HISE from the develop branch (Feb '23)

                        ulrikU 1 Reply Last reply Reply Quote 0
                        • ulrikU
                          ulrik @Frankbeat
                          last edited by

                          @Frankbeat You can't have the same variables for both samplers, you have to duplicate them and also have a separate for-loop for the Sampler2 samples
                          also Sampler2.selectSounds('');

                          Hise Develop branch
                          MacOs 15.3.1, Xcode 16.2
                          http://musikboden.se

                          FrankbeatF 1 Reply Last reply Reply Quote 1
                          • FrankbeatF
                            Frankbeat @ulrik
                            last edited by

                            @ulrik Alright, now it works… Thank you very much, again!

                            Using HISE from the develop branch (Feb '23)

                            Christoph HartC 1 Reply Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart @Frankbeat
                              last edited by

                              Changing the sample properties like this might lead to a few edge case issues (eg. if you load a sample map in a preset and then change the pan it might cause order-of-initialization issues), also it's a very heavyweight operation so you can't automate it.

                              The stereo FX with scripted voice start modulator solution looks like this:

                              HiseSnippet 1431.3oc2X0saSbDEd1jLoXCkBnnpJ0aFg5ENTvX2BoUBghyeFYAArxF9oWglr6wwixtyrc1wgXPU8l97zWgxiPeDZeC3Mn8Lyt1dcvJXaU.Q8EIdNybly2424bbasJ.RSUZhWo86m.DuKP86KMc2pKWHIs1l3cQ5t7TCnYYj1reBOMEBIddKdOKAuRKQbedy5axi3x.XDIB4IJQ.7.QrvLhZ6F2WDE0jGB6KhKb5a0nUfRtkJR0CwyhzZjDdvQ7CgGxsGaAJwa4cBEFk12vMPJdlMUg886pdgL67OQjJNHBrKpS7wKJiLYqthnv1Cz0TBwi1djluXlluBcWQnXH8QVfK41fMhih1.uENKHUeFfjWAHsTFjtL0OPKRLi1whmySaIQGRGNZpKBkryR7dMcKEd.ooZL+HnoFWLjgJqUq10Y3eV8Nc5ICLBkjojOTYfGIqrZ4WUtT4eoL6za0oyD2yJFsJJBzSbaq2UeVLVQ1K9.Pec1w7ndvvChp+31zkmNaZPlVW3fJYKov7nDHecSUTn0VY+9a6AH4lMquHGg3QMNOwEy8D9QhPPSD3k7Yz6KUGTm3.ewXdxiasM2vGbM3MhRIAzFgUY71FNFyIxbvknaCoGYTItyFmnjV46c92oPOYj.EM5ObwqOrQpou0zrr6fjXQXXDzVkJrl9QL8Wq2QDEmZvquULlhQ7tB8wo.KD5v6EYXoGgA+QB4QP39JWtmANAQ14n9IZfGRRFX3Zgn5Knt77rsPjlv0XJKFxY2bHKj2N.GSsTg8h3lwy2rEVx2vh5hA41HYIpM8KV3YFRBqclIgSKDuLssvDzcxXbgIfQLX38AFyKc84zc5zABLi.3RzlOadqSM8h+hYh+7TegDbua3D9W5VydJ+XfcOPBZqwq9Y7zweNsOcjL0Oc7n.CJ980bYZhJcrK1GhE6iYZoEIhA+M0vOum0aVj9VJtdha8l0ahJ4D4wma5ocgEaDq5IMiEFr339gkltZaimQT37S3gjk9H711+MoUeDy7G642RCvnuHNIB1QdLDgUvcX7JXIaWMxATGOvdWkTkzUIEAE856AXk1CODzEw9DUnMLFromQTVowdPDvKFA+MMd.F4w0ncBlSawr2JxD8WeEMCtLa1H6S2J1K9+5J1i4NoYxuL0GedFTnLsB+B4KYMe13gys4EJS+SMdpHDqwWfvG9XtKQQLw93WiX4LL9048nk0.jgqMCwrCtmt0n2IZ2Tjnh3ZaeD4Mzuvut.EecK0f8IqYY2js4N1cYCZzmG5nT4pY6d0qyvt7wd7KWtPW2ifXkiseskLDNw008MuIqIfYGLSWfIwN9YI4cLxpXIsKpyXShrfHD6rWfOAy5hsRy3LMzAiavWtYFEycQCuBjYSWN1JoUhPnaCmbWkwkgrz.dDvDFKi2nNqZ0pr5kKEoPxH+5XrmUTAqjK5pGBF6nHOzMwPkUY2fs1spVaU1Mc++N3jCVguQRRTemjRcFhxkFbUW6tErb1a6I111qr5.Ns7LzVIAHL0BLMfujKQ8LdX7V1vJrC.yK.Pxp4Tl542AptNqyA.iiPQfpMOk4bdboSUcXKKWanMV0YjwoZ4R4Bsx.n+sr5VM8ZrZUu8cN0jT49TUxocoy1nZy3.YycV9LNh0vQGdOLi0Ed2REGxh5YEV+AeY5Ft5M+A5gS7EuzA4Wsxueu+9k+15wE63kPh4mTLsOsWmNhSbSZMqSlQ1S0yHjGtKGYxhYLIwGaDN.vplRIDkZg+BVqe15ZCTGePF5V7O3m7MqaW6kuY8Aa9AQFw7.s54AYwE15smyQAiPjteAnRzcsqYCm4lRqUsl0MHddPf8IzaTmPlLOe2bvy2OG7bq4fmaOG7r1bvyOLG77imIO1gG1nmQEm8TLRn8Nt7ROucjbrjf6cNx+xakGYp
                              

                              relevant code (you might need to scale the range according to what you want):

                              function onVoiceStart(voiceIndex)
                              {
                              	// Fetch the note position (the Message class will hold a reference to 
                              	// the note on that started the voice) and scale it to -1 ... 1
                              	local normPos = (Message.getNoteNumber() - 64.0) / 64.0;
                              	
                              	// Apply the spread
                              	normPos *= SpreadKnob.getValue();
                              	
                              	// the function needs to return a modulation value between 0 and 1
                              	// that will be applied as constant to the stereo position of the voice.
                              	return (normPos + 1.0) * 0.5;
                              }
                              
                              FrankbeatF ulrikU 2 Replies Last reply Reply Quote 1
                              • FrankbeatF
                                Frankbeat @Christoph Hart
                                last edited by

                                @Christoph-Hart said in Change panorama position of a noteOn Message:

                                Changing the sample properties like this might lead to a few edge case issues (eg. if you load a sample map in a preset and then change the pan it might cause order-of-initialization issues), also it's a very heavyweight operation so you can't automate it.

                                The stereo FX with scripted voice start modulator solution looks like this:

                                HiseSnippet 1431.3oc2X0saSbDEd1jLoXCkBnnpJ0aFg5ENTvX2BoUBghyeFYAArxF9oWglr6wwixtyrc1wgXPU8l97zWgxiPeDZeC3Mn8Lyt1dcvJXaU.Q8EIdNybly2424bbasJ.RSUZhWo86m.DuKP86KMc2pKWHIs1l3cQ5t7TCnYYj1reBOMEBIddKdOKAuRKQbedy5axi3x.XDIB4IJQ.7.QrvLhZ6F2WDE0jGB6KhKb5a0nUfRtkJR0CwyhzZjDdvQ7CgGxsGaAJwa4cBEFk12vMPJdlMUg886pdgL67OQjJNHBrKpS7wKJiLYqthnv1Cz0TBwi1djluXlluBcWQnXH8QVfK41fMhih1.uENKHUeFfjWAHsTFjtL0OPKRLi1whmySaIQGRGNZpKBkryR7dMcKEd.ooZL+HnoFWLjgJqUq10Y3eV8Nc5ICLBkjojOTYfGIqrZ4WUtT4eoL6za0oyD2yJFsJJBzSbaq2UeVLVQ1K9.Pec1w7ndvvChp+31zkmNaZPlVW3fJYKov7nDHecSUTn0VY+9a6AH4lMquHGg3QMNOwEy8D9QhPPSD3k7Yz6KUGTm3.ewXdxiasM2vGbM3MhRIAzFgUY71FNFyIxbvknaCoGYTItyFmnjV46c92oPOYj.EM5ObwqOrQpou0zrr6fjXQXXDzVkJ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kZg+BVqe15ZCTGePF5V7O3m7MqaW6kuY8Aa9AQFw7.s54AYwE15smyQAiPjteAnRzcsqYCm4lRqUsl0MHddPf8IzaTmPlLOe2bvy2OG7bq4fmaOG7r1bvyOLG77imIO1gG1nmQEm8TLRn8Nt7ROucjbrjf6cNx+xakGYp
                                

                                relevant code (you might need to scale the range according to what you want):

                                function onVoiceStart(voiceIndex)
                                {
                                	// Fetch the note position (the Message class will hold a reference to 
                                	// the note on that started the voice) and scale it to -1 ... 1
                                	local normPos = (Message.getNoteNumber() - 64.0) / 64.0;
                                	
                                	// Apply the spread
                                	normPos *= SpreadKnob.getValue();
                                	
                                	// the function needs to return a modulation value between 0 and 1
                                	// that will be applied as constant to the stereo position of the voice.
                                	return (normPos + 1.0) * 0.5;
                                }
                                

                                With this solution, does the knob have to be added inside the Script Modulator? So I have to add the same knob to each of my Samplers?

                                Using HISE from the develop branch (Feb '23)

                                Christoph HartC 1 Reply Last reply Reply Quote 0
                                • Christoph HartC
                                  Christoph Hart @Frankbeat
                                  last edited by

                                  Yes and it might make sense to connect it to an external script if you have more than two samplers to keep the redundancy low.

                                  ulrikU 1 Reply Last reply Reply Quote 1
                                  • ulrikU
                                    ulrik @Christoph Hart
                                    last edited by

                                    @Christoph-Hart this seems to be a better way, and cleaner!

                                    Hise Develop branch
                                    MacOs 15.3.1, Xcode 16.2
                                    http://musikboden.se

                                    1 Reply Last reply Reply Quote 0
                                    • ulrikU
                                      ulrik @Christoph Hart
                                      last edited by

                                      @Christoph-Hart And using this way, would it be possible to set up a mixer for just one sampler, gain and pan for each note?

                                      Hise Develop branch
                                      MacOs 15.3.1, Xcode 16.2
                                      http://musikboden.se

                                      1 Reply Last reply Reply Quote 0
                                      • FrankbeatF
                                        Frankbeat
                                        last edited by

                                        Wow, this works like a charm! Thank you very much!
                                        This way, it is even easier to set the right spread amount across the mapping range. I helped myself a little by printing it to console, since you wrote it has to return values between 0 and 1.

                                        function onVoiceStart(voiceIndex)
                                        {
                                        	local normPos = (Message.getNoteNumber() - 45) / 45;
                                        	normPos *= spreadKnob.getValue();
                                        	local newNormPos=(normPos) * 3.21;
                                        	// dev state only: Console.print(newNormPos);
                                        	return newNormPos;
                                        }
                                        

                                        The noteNumber 45 is my lowest mapped key here, but I don't know how I came to end up with this modified formula omitting the +1. But not to complain – it works. 😀

                                        Using HISE from the develop branch (Feb '23)

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

                                        36

                                        Online

                                        1.7k

                                        Users

                                        11.7k

                                        Topics

                                        101.9k

                                        Posts