HISE Logo Forum
    • Categories
    • Register
    • Login

    How do you get the sample rate in SNEX?

    Scheduled Pinned Locked Moved Solved ScriptNode
    6 Posts 2 Posters 293 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.
    • griffinboyG
      griffinboy
      last edited by griffinboy

      How do you get hold of sample rate inside of a SNEX node?

      I need to use sample rate in some of my snex calculations.
      (eg. Filtering)

      Is there a way to get hold of the sample rate being used in the rest of HISE? and if so, how do I get that value? Or is there a way to get the sample rate of the user's daw project.

      I want to be able to pass it into code like so.

      11f8cf00-a4e1-4f29-ad36-741749c3e8aa-image.png

      It's quite important for my calculations.
      Thanks.

      Christoph HartC griffinboyG 2 Replies Last reply Reply Quote 0
      • griffinboyG griffinboy marked this topic as a question on
      • Christoph HartC
        Christoph Hart @griffinboy
        last edited by

        @griffinboy the prepare callback has an argument that will provide you with the processing specs.

        ps.sampleRate
        ps.numChannels
        ps.blockSize
        

        If you're using oversampling, it will also be factored in already, so just take whatever value is being passed there.

        griffinboyG 1 Reply Last reply Reply Quote 1
        • griffinboyG
          griffinboy @Christoph Hart
          last edited by griffinboy

          @Christoph-Hart
          Thank you!

          You'll have to forgive me for not knowing how to pass it in, I am not very familiar with C++ yet

          f36a9630-0bc0-458d-8b78-17a5ccd4577a-image.png

          ps. <- does not seem to appear in the HISE documentation. I assume this is prepare specs

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

            @griffinboy check this example, it saves the sample rate to be used to calculate the pitch factor of the sample playback:

            Link Preview Image
            HISE | Examples | Scriptnode Snippets

            Examples in the category Scriptnode

            favicon

            (docs.hise.audio)

            griffinboyG 1 Reply Last reply Reply Quote 1
            • griffinboyG
              griffinboy @Christoph Hart
              last edited by

              @Christoph-Hart Perfect thanks for your time

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

                @griffinboy

                The working answer:

                // Get sampleRate inside a snex node
                double sr = 0.0;
                void prepare(PrepareSpecs ps)
                {	
                	sr = ps.sampleRate;
                }
                
                1 Reply Last reply Reply Quote 2
                • griffinboyG griffinboy has marked this topic as solved on
                • First post
                  Last post

                22

                Online

                1.8k

                Users

                12.1k

                Topics

                105.0k

                Posts