HISE Logo Forum
    • Categories
    • Register
    • Login

    How do you Tempo Sync ADSR?

    Scheduled Pinned Locked Moved General Questions
    60 Posts 5 Posters 830 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 @Mighty23
      last edited by

      @Delamere Also it's worth noting that any changes you make to the source code will be overwritten the next time you grab the latest version from github, unless you fork the source code and use git to manage changes.

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

      1 Reply Last reply Reply Quote 1
      • D
        Delamere @d.healey
        last edited by

        @d-healey So I could use a Linear Knob that goes from 0.0 to 23.0, as I will be using a Film Strip for my Knobs that won't display the value.

        Screenshot 2025-05-27 at 13.10.24.png

        Screen Recording 2025-05-27 at 13.19.08.mov

        But it's still not possible to go faster than 1/64t, so I'm guessing the only way is to modify the source code like @Mighty23 mentioned. This seems a bit too advanced for me though at this moment in time, but I will look into it.

        Would I still need to change the source code if I was to use the Transport Handler & Scripting? I really don't understand how to do it that way.

        Thanks.

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

          @Delamere said in How do you Tempo Sync ADSR?:

          Would I still need to change the source code if I was to use the Transport Handler & Scripting?

          There would be no need to change the source code as far as I can see, you'd just take the tempo value and convert it to ms.

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

          D 1 Reply Last reply Reply Quote 0
          • D
            Delamere @d.healey
            last edited by

            @d-healey Okay thanks, if you have any time, could you please explain how to write a script that will mean I can change the AHDSR to be Tempo Synced for any Sampler I apply it to? Similar to what I did in scrip node but with the option to go to 0ms for the Attack, Hold, Sustain & Release if they're not needed.

            Thanks.

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

              @Delamere said in How do you Tempo Sync ADSR?:

              could you please explain how to write a script

              Well I already explained it, I think what you're asking is for me to write it, but I think it would be better if you learned how to do it.

              Start with that scripting 101 video I mentioned.

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

              D 1 Reply Last reply Reply Quote 0
              • D
                Delamere @d.healey
                last edited by

                @d-healey Sorry for the confusion, I wasn't asking for you to write it, just to explain it in simpler terms, for someone that's new to scripting. I know what I wan't to do & there are only several things that require scripting to make my Plug-ins do what I need them to. But no matter how much I read on the HISE website I just can't take it in properly or find what I need. I have watched the video you mentioned previously & I will watch it again and see if it makes more sense to me this time. I find videos easier to understand. But I am finding Youtube to be very limited when it comes to HISE videos based on the things I need to do. I can't find anything based around the Transport Handler or Tempo Syncing.

                Thanks.

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

                  @Delamere said in How do you Tempo Sync ADSR?:

                  I can't find anything based around the Transport Handler or Tempo Syncing.

                  It's that thing about teaching a man to fish.

                  If I show you how to do the task you want (I write the code for you basically), you won't really be any further ahead with scripting than you are now. When you run into another task that requires scripting you'll be asking again for a basic explanation.

                  If you take the time to go through the fundamentals, make some basic projects, write a few scripts. Then when I explain some concepts like callback functions, and setting attributes, you'll understand what I mean and be able to implement them in a way that fits your project.

                  It's not a quick process, there is a learning curve, but ultimately it gives you control over you projects and allows you to implement the features you want in a way that you understand.

                  But here's the explanation of what you need to do:

                  Use transport handler callback to get the host tempo (BPM)

                  Within your GUI knob's control callbacks use the BPM and the knob's value (tempo sync) to calculate milliseconds then call .setAttribute() to set the value of the ahdsr knobs to the millisecond value you calculated.

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

                  D 2 Replies Last reply Reply Quote 2
                  • D
                    Delamere @d.healey
                    last edited by

                    @d-healey Okay I understand what you mean and agree with what you're saying. I am currently watching your video again. Thank you for your help.

                    1 Reply Last reply Reply Quote 1
                    • D
                      Delamere @d.healey
                      last edited by Delamere

                      @d-healey

                      Since we last spoke, I have been constantly learning HISE scripting & I now understand a lot more about it.

                      I have made simpler scripts based on other things I wanted to do, but I am really struggling to understand how to tempo sync the AHDSR knobs & this is the most important thing I need for my plug-ins. If you could please explain a few things to help me understand it more. This is what I’m stuck on..

                      const var Transport_Handler = Engine.createTransportHandler();
                      // Transport_Handler: Provides a Callback that tells the script when the tempo of the DAW has changed.

                      Transport_Handler.setOnTempoChange(var sync, var f)
                      // So for this Callback do I use a function & if so, is it an inline function or function?

                      • “You can use the Tempo”

                      Const var Get_Host_Bpm = Engine.getHostBpm(); - Is that right?

                      • Combined with the value of the Knobs from the Interface (Which will be Tempo Synced) 1/4 etc.

                      How do you get the value of the Knobs & where do I put them?

                      • To calculate the number of milliseconds the Attack & Release should be.

                      How do you calculate the number of milliseconds the Attack & Release should be?

                      • You can use that calculated value (milliseconds) to set the Attack & Release Knobs of the envelope. .setAttribute()

                      How do you set the Knobs of the envelope?

                      What do I do with this.. Engine.getMilliSecondsForTempo(int tempoIndex) ?

                      Thank you for your help.

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

                        @Delamere
                        If you use code tags (back ticks) it will help with formatting your code on the forum to make it easier to read. This button on the toolbar will do the same thing: c056cca5-cc18-4c88-b5d5-f797bd4f1b7f-image.png

                        If you take a look at the snippet included in the documentation, I think most of your questions will be answered, with a working example too.

                        It includes an example of setOnTempoChange callback

                        // Now we'll register another set of functions as asynchronous callbacks to update the UI
                        
                        th.setOnTempoChange(false, function(newTempo)
                        {
                            Tempo.set("text", newTempo + " BPM");
                        });
                        

                        @Delamere said in How do you Tempo Sync ADSR?:

                        Const var Get_Host_Bpm = Engine.getHostBpm(); - Is that right?

                        You won't need this since you are getting the host bpm in the tempo change callback.

                        @Delamere said in How do you Tempo Sync ADSR?:

                        How do you get the value of the Knobs & where do I put them?

                        If you're using a control callback for the knob the knob's value will be passed in as the second parameter.

                        @Delamere said in How do you Tempo Sync ADSR?:

                        How do you calculate the number of milliseconds the Attack & Release should be?

                        Some formula involving the tempo in BPM which you got from the transport handler, the knob's value as a tempo (1/4, 1/64t, etc.). I don't know what the exact formula is but it's probably not complicated. ChatGPT can be helpful here, as long as you know what you want so you can check it's giving your the correct output.

                        @Delamere said in How do you Tempo Sync ADSR?:

                        How do you set the Knobs of the envelope?

                        Use setAttribute(). I've shown this in several videos, this is probably a good one to start with:
                        https://www.youtube.com/watch?v=ylWbVR77Nhg

                        @Delamere said in How do you Tempo Sync ADSR?:

                        What do I do with this.. Engine.getMilliSecondsForTempo(int tempoIndex) ?

                        That probably won't be useful here actually, it's only good for taking the value of a knob in tempoSync mode (tempoIndex) and converting it to ms. But since the tempoSync mode doesn't have all the values you need and you're rolling your own system you won't be using this function.

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

                        D 1 Reply Last reply Reply Quote 0
                        • D
                          Delamere @d.healey
                          last edited by

                          @d-healey Okay thank you that's very helpful. This is the script so far, can you please let me know if I'm doing it right?

                          HiseSnippet 1626.3oc2Y0saaaCElJIps18u0g8.HXrKb2xRrSZRaQQQrisyhQh+AVtEq2r.ZIZahJS5IQmVugBzGgcauauF6t9HrGg9Hz2fMRJIKpDIGGi00lkbS347wy4iejT7Pl1tTKjmG0Enks6zwHf1szMmRXCqLDhIf5UAZesdWznwTCtYKixGV0rCX+oigddHafl1p+n.mVl0.xe93d6CcfDKTjI.34TrE5X7HLKxZ6RGgcbN.Zi5hGof9AkpaQIUnNzIbNspdAvXn0KgCPMgBXqnCND5MDn8c5asUeqGUnvi1d6cJ.gaaCgOnHZ6Gi5uaeqcJ73B181o.+2cAZWqlMlQcMYPFxCns19T6olCouh3mfmi8v8bPhFEAl7L6a9.pisXHJrBpLD6X2NTr7..M81QR2p9R22n2.aimYORB+JoCindnJfZqDmdqFidEUoWAE5k.kzTnzZ9T5d5lVt3wrHOB9bS85DFxsOjOOoREerfUN4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odsZwAoANDoQ8trh6qR3oepJs9W6t1KJEumdaLyZXxbbkD3H+yoeJ3XvKTba8Z86irXQDbM8C9oOMOGgZ5uie5uotIupH4UkkIOi+aMYTdNunzesnunz3E9EkZYwfmF9tCdwBrIZDtKeujmpwm4gNvE8KcDSfp1qPgtI55i6c.eblXeLgrItxUBkGQmPXwl4WcdOTUwk7gpV6KtGp5Jv96Xuk1c843008e8SA0B+aUF0fRniGRIXK0I0NHdE7CFv+JrBOSj79EwTYh6oJKI+vdxiPOm0fJdTRjukiQmxORQwrrZBk19mHqj1vyzhwY+O8qfplEsg+4VKiXWb9hs9BtfHrrPC4N7K8pg0VrUCye+zht38Ngb0eF4KaxFTU2UAc8tgEgckPXmU00UAoctEqr5+uKVoCcBCSFz.x+Zsnx5lSFYxKXvBI9uMPPNhGoPaEwg99sKHZ6Ww.wV13u4+D3rnnsVfyhgN+OIGifVtzSr7udu3aq2PZgOtIx+AZYzaHZaT77WnmWyN9DKq3g5bcbqksiaurc7AKaG2YY63tKaGe3x1wGcwcTTYV4IL5H+sl.Pi10jO.ilVMh3QPk6H.+Cv345RK
                          

                          How come it says this?

                          Interface:! Line 9, column 14: Unknown function 'set' {SW50ZXJmYWNlfHwyMDN8OXwxNA==}

                          @d-healey said in How do you Tempo Sync ADSR?:

                          Some formula involving the tempo in BPM which you got from the transport handler

                          Where is the tempo in BPM that I got from the Transport Handler?

                          @d-healey said in How do you Tempo Sync ADSR?:

                          you can check it's giving your the correct output

                          How do I check?

                          Thanks again this is very helpful.

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

                            @Delamere said in How do you Tempo Sync ADSR?:

                            How come it says this?

                            Interface:! Line 9, column 14: Unknown function 'set' {SW50ZXJmYWNlfHwyMDN8OXwxNA==}

                            Because you don't have a label called "Tempo" on your interface - I would avoid copying directly from the snippet in the docs and instead use it as a reference for writing your own script from scratch.

                            @Delamere said in How do you Tempo Sync ADSR?:

                            Where is the tempo in BPM that I got from the Transport Handler?

                            You need to store it in a variable.

                            @Delamere said in How do you Tempo Sync ADSR?:

                            How do I check?

                            Give a BPM, let's say 120, and pick a tempo sync value, let's say 1/4. With those values what would you expect the millisecond result to be. - Pass something like this to ChatGPT and ask it to give you a formula for that calculation. Then use a calculator to test the formula with various inputs.

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

                            D 1 Reply Last reply Reply Quote 0
                            • D
                              Delamere @d.healey
                              last edited by

                              @d-healey okay thanks.

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

                              18

                              Online

                              1.7k

                              Users

                              11.8k

                              Topics

                              103.2k

                              Posts