Forum
    • Categories
    • Register
    • Login

    Sample Rate changes

    Scheduled Pinned Locked Moved General Questions
    10 Posts 4 Posters 42 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.
    • resonantR
      resonant
      last edited by resonant

      Is there a function that can automatically run when the DAW's sampling rate changes? Or how can we achieve this?

      David HealeyD griffinboyG 2 Replies Last reply Reply Quote 0
      • David HealeyD
        David Healey @resonant
        last edited by

        @resonant Transport handler perhaps https://docs.hise.audio/scripting/scripting-api/transporthandler/index.html

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        resonantR 1 Reply Last reply Reply Quote 0
        • resonantR
          resonant @David Healey
          last edited by

          @David-Healey There doesn't seem to be anything related to sample rate in Transport Handler :(

          ustkU 1 Reply Last reply Reply Quote 0
          • griffinboyG
            griffinboy @resonant
            last edited by griffinboy

            @resonant

            We do have it in c++ nodes (function called prepare() gets loaded with sample rate when it changes)

            If you need Hise to know about sr changes you can make a c++ node that then uses a global cable to trigger a hise global cable callback when sr changes...
            But yeah that's obviously a workaround.

            Maybe Christoph can add a Hise function for this so that there is an easier way.
            But if its something you absolutely need, I can show you how to set it up.

            ustkU 2 Replies Last reply Reply Quote 2
            • ustkU
              ustk @resonant
              last edited by ustk

              @resonant There is no callback that can be automatically called when the audio state changes, but you can periodically call Settings.getCurrentSampleRate()

              EDIT: or like @griffinboy suggested by getting it from the audio thread...

              Hise made me an F5 dude, any other app just suffers...

              1 Reply Last reply Reply Quote 0
              • ustkU
                ustk @griffinboy
                last edited by

                @griffinboy you don't need a cable, just read a global var that updates from any scriptFX module

                function prepareToPlay(sampleRate, blockSize)
                {
                	g_SAMPLERATE = sampleRate;
                }
                

                from there you can compare to the old value and create your own callback

                Hise made me an F5 dude, any other app just suffers...

                1 Reply Last reply Reply Quote 0
                • ustkU
                  ustk @griffinboy
                  last edited by ustk

                  @griffinboy @resonant Oh wait! Actually there's a broadcaster for this!

                  // Broadcaster definition
                  const var SamplerateChanged = Engine.createBroadcaster({
                    "id": "SamplerateChanged",
                    "args": ["sampleRate", "blockSize"],
                    "tags": []
                  });
                  
                  // attach to event Type
                  SamplerateChanged.attachToProcessingSpecs("");
                  
                  // attach first listener
                  SamplerateChanged.addListener("", "md", function(sampleRate, blockSize)
                  {
                  	Console.print(sampleRate);
                  });
                  

                  Hise made me an F5 dude, any other app just suffers...

                  resonantR 2 Replies Last reply Reply Quote 4
                  • resonantR
                    resonant @ustk
                    last edited by

                    @ustk This is it, I will try this thanks!

                    1 Reply Last reply Reply Quote 0
                    • resonantR
                      resonant @ustk
                      last edited by

                      By the way, attachToProcessingSpecs broadcaster also seems to get buffer size!

                      ustkU 1 Reply Last reply Reply Quote 0
                      • ustkU
                        ustk @resonant
                        last edited by

                        @resonant absolutely:

                        function(sampleRate, blockSize)
                        blockSize = buffer size

                        Hise made me an F5 dude, any other app just suffers...

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

                        16

                        Online

                        2.2k

                        Users

                        13.5k

                        Topics

                        117.7k

                        Posts