HISE Logo Forum
    • Categories
    • Register
    • Login

    Accurate range conversion

    Scheduled Pinned Locked Moved General Questions
    21 Posts 3 Posters 651 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.
    • d.healeyD
      d.healey @toxonic
      last edited by d.healey

      @toxonic I didn't open your snippet I just answered the question :p

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

      toxonicT 1 Reply Last reply Reply Quote 0
      • toxonicT
        toxonic @d.healey
        last edited by toxonic

        @d-healey Hehehe, okay.... :D Then it's seems not to be an issue of my conversion function, that there are inaccuracies... any ideas?

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

          @toxonic Why do you want to use macros for this?

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

          toxonicT 1 Reply Last reply Reply Quote 0
          • toxonicT
            toxonic @d.healey
            last edited by

            @d-healey To be honest, I just try to learn scripting in HISE, and I'm at the very beginning.
            I have several Faust FX which can be dynamically loaded into 6 Hardcoded Master FX Slots.
            Some of these FX have BPM Knobs, which should automatically receive tempochanges by the DAW using Transport Handler. Since i have no idea, how to connect them in that moment, the effect gets loaded into a Hardcoded FX Slot, without using an array, which will be problematic as soon as the effect is getting removed again from the Slot, i thought it might be a simpler option to use a Macro Control and get all "BPM" buttons connected to it, when the effect gets loaded. (excuse that awkward explanation and my poor english, but i'm afraid, i can't do better ;-) ).

            Btw, i tried to "borrough" your Helpers.js file and put it into the default location for global scripts, but when I try to include it via:

            'Helpers.js'include({GLOBAL_SCRIPT_FOLDER}Helpers.js);�
            

            HISE tells me

            Master Chain:! Line 1, column 1: File /home/toxonic/Audio/HISE_Projects/Test/Scripts/Helpers.js not found�
            

            This is not the global script path at all. Is the wildcard broken?

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

              @toxonic

              I think you should just be using setAttribute rather than macros for this. Another option is to put a tempo knob on your UI and connect that to the knob of your effect, and update its value inside your tempo change callback.

              Did you set the global script folder in project preferences? Also why do you have 'Helpers.js' before the include?

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

              toxonicT 1 Reply Last reply Reply Quote 0
              • toxonicT
                toxonic @d.healey
                last edited by

                @d-healey said in Accurate range conversion:

                @toxonic

                I think you should just be using setAttribute rather than macros for this. Another option is to put a tempo knob on your UI and connect that to the knob of your effect, and update its value inside your tempo change callback.

                I will try this out, i could make the UI Knob invisible too.

                Did you set the global script folder in project preferences? Also why do you have 'Helpers.js' before the include?

                Well, i tried it according to the tool tip
                Screenshot from 2022-11-25 18-14-38.png

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

                  @toxonic I think that tool tip is badly worded. I have a video on Patreon about the Global Scripts Folder - https://www.patreon.com/posts/sharing-scripts-72393541

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

                  Christoph HartC 1 Reply Last reply Reply Quote 1
                  • Christoph HartC
                    Christoph Hart @d.healey
                    last edited by

                    You're a bit off-track and scripting and macro controls are definitely the wrong tool for the job.

                    Some of these FX have BPM Knobs, which should automatically receive tempochanges by the DAW using Transport Handler. Since i have no idea, how to connect them in that moment

                    Just use a tempo-sync node and connect it to whatever faust parameter you need to be synced. The tempo sync node automatically converts the current tempo to a ms value (and if you want to connect it to a frequency parameter you can use a converter node with the appropriate mode).

                    toxonicT 1 Reply Last reply Reply Quote 2
                    • toxonicT
                      toxonic @Christoph Hart
                      last edited by

                      @Christoph-Hart Hmm, but the tempo sync node updates tempo changes in 64t at best, correct? Thats 's not really accurate, right?

                      toxonicT 1 Reply Last reply Reply Quote 0
                      • toxonicT
                        toxonic @toxonic
                        last edited by

                        Okay, i got it working now by scanning the array with all HardcodedMasterFX References for a parameter called "bpm" and if available, assign to the Transport Handler function.

                        const var HardcodedMasterFX = [Synth.getEffect("HardcodedMasterFX1"), Synth.getEffect("HardcodedMasterFX2"),
                        Synth.getEffect("HardcodedMasterFX3")];
                        
                        const var th = Engine.createTransportHandler();
                        
                        th.setOnTempoChange(false, function(newTempo)
                        {
                        	for (x in HardcodedMasterFX)
                        	{
                        		var bpmknob = x.getAttributeIndex("bpm");
                        		if (bpmknob != -1) x.setAttribute(bpmknob, newTempo);
                        		else continue;
                        	}
                        	
                        });
                        

                        The result of one day of trial and error... sad but true! :-( But yeah, every beginning is difficult! ;-)

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

                          Hmm, but the tempo sync node updates tempo changes in 64t at best, correct? Thats 's not really accurate, right?

                          No, that's just the smallest divisor. The host tempo is converted to milliseconds using the full double precision but if your faust class expects a parameter as BPM, you will have to convert it back to BPM values.

                          The formula is BPM = 60.0 / (ms * 0.001) so you could just use a control.cable_expr node, but I've also added a converter mode to the control.converter node that does this for you.

                          7380168f-5dc4-407c-b3db-b677f4ca1b4b-image.png

                          toxonicT 1 Reply Last reply Reply Quote 2
                          • toxonicT
                            toxonic @Christoph Hart
                            last edited by

                            @Christoph-Hart said in Accurate range conversion:

                            No, that's just the smallest divisor. The host tempo is converted to milliseconds using the full double precision....

                            Aha, okay, then i got that wrong. It seemd to me, that it only updates the ms values in dependence to the tempo.

                            ...but if your faust class expects a parameter as BPM, you will have to convert it back to BPM values.
                            The formula is BPM = 60.0 / (ms * 0.001) ....

                            I have already converted the values inside some of the Faust files according this formula.

                            ....so you could just use a control.cable_expr node, but I've also added a converter mode to the control.converter node that does this for you.

                            Ah, nice, that you already added the MS2BPMModeto the converter node! :-)
                            Just one more question: The solution i posted in my above post seems to me quite satisfying at the moment, but due to my lack of experience i just want to ask you, if you think, if there's something to complain about. What do you think?

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

                              @toxonic Yes you're using a asynchronous tempo callback so the tempo update will be dragged through the UI thread and might be updated a few milliseconds later if the UI is busy.

                              Whether you can live with that kind of hack is up to you, but the cleaner solution is to use a tempo_sync node like I suggested.

                              toxonicT 1 Reply Last reply Reply Quote 0
                              • toxonicT
                                toxonic @Christoph Hart
                                last edited by

                                @Christoph-Hart What about putting it into an inline function to get it synchronous?

                                const var th = Engine.createTransportHandler();
                                
                                th.setOnTempoChange(true, TempoChange);
                                
                                inline function TempoChange(newTempo)
                                {
                                	for (x in HardcodedMasterFX)
                                	{
                                		local bpmknob = x.getAttributeIndex("bpm");
                                		if (bpmknob != -1) x.setAttribute(bpmknob, newTempo);
                                		else continue;
                                	}
                                	
                                };�```
                                Christoph HartC 1 Reply Last reply Reply Quote 0
                                • Christoph HartC
                                  Christoph Hart @toxonic
                                  last edited by

                                  @toxonic Yes, but then you get a string comparison function in a loop whenever the tempo changes in the audio callback.

                                  toxonicT 1 Reply Last reply Reply Quote 1
                                  • toxonicT
                                    toxonic @Christoph Hart
                                    last edited by

                                    @Christoph-Hart Yes, right - you mean, this is a question of CPU usage? I thought, it would maybe suck more ressources, if i have multiple instances of the tempo sync node / converter nodes running ? No?

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

                                      @toxonic It won't burn your CPU to use this, but it's vastly more ineffective than a tempo sync node, which is just a virtual function call with the new tempo value which is basically free unless you have thousands of tempo sync nodes (with your solution you also get the overhead of calling into HiseScript).

                                      It's not critical per se but you asked me what's wrong with the code and I would do it differently.

                                      toxonicT 1 Reply Last reply Reply Quote 1
                                      • toxonicT
                                        toxonic @Christoph Hart
                                        last edited by

                                        @Christoph-Hart okay, thank you for the explanation. I'll change this in my project after i compiled the latest commit for the converter node. 😉

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

                                        20

                                        Online

                                        1.7k

                                        Users

                                        11.8k

                                        Topics

                                        103.0k

                                        Posts