HISE Logo Forum
    • Categories
    • Register
    • Login

    Accurate range conversion

    Scheduled Pinned Locked Moved General Questions
    21 Posts 3 Posters 660 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.
    • 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

                        16

                        Online

                        1.8k

                        Users

                        12.0k

                        Topics

                        104.3k

                        Posts