HISE Logo Forum
    • Categories
    • Register
    • Login

    Getting the sample rate for an externalData object?

    Scheduled Pinned Locked Moved C++ Development
    6 Posts 2 Posters 38 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.
    • O
      Orvillain
      last edited by

      Is it possible to get the sample rate for an externalData object?

      We can do the following:

      	void setExternalData(const ExternalData& data, int index)
      	{
      		if (data.isNotEmpty())
      		{
      			auto buffer = data.toAudioSampleBuffer();
      			float sampleRate = 44100.0f; // Replace with actual rate if available
      
      			// down sampling and other pre-processing stages go here
      
      			hise::JSONObject obj;
      			obj[String("length")] = buffer.getNumSamples();
      			obj[String("RMS")] = buffer.getRMSLevel(0, 0, buffer.getNumSamples());
      			obj[String("knobValue")] = value;
      
      			this->sendDataToGlobalCable<GlobalCables::dataCable>(obj);
      		}
      	}
      

      But there does not seem to be a way to get the sample rate for either the data object or the buffer itself.

      I'm writing a node that makes a copy of an audio buffer and downsamples it, but I would really like to track the sample-rate of the original file, so I can calculate the sample-rate of my downsampled audio.

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

        @Orvillain data.sampleRate should be populated with the file samplerate if the audio buffer comes from an external file.

        O 1 Reply Last reply Reply Quote 1
        • O
          Orvillain @Christoph Hart
          last edited by

          @Christoph-Hart said in Getting the sample rate for an externalData object?:

          @Orvillain data.sampleRate should be populated with the file samplerate if the audio buffer comes from an external file.

          Dohhhh. I was trying data.getSampleRate() - my mistake!

          Is there anywhere where that sort of thing is documented Chris? If not, where should it be? I can get the ball rolling.

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

            Link Preview Image
            HISE | ScriptNode | ExternalData

            My Funky Summary

            favicon

            (docs.hise.dev)

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

              @Christoph-Hart haha, My Funky summary, lol that autogenerator has gone crazy...

              O 1 Reply Last reply Reply Quote 1
              • O
                Orvillain @Christoph Hart
                last edited by

                @Christoph-Hart

                🤣

                Cool thanks! I'm still figuring out how all of this interfaces, but getting there and making good progress!

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

                13

                Online

                1.7k

                Users

                11.8k

                Topics

                102.3k

                Posts