Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what about variable block size? #2

Closed
menzi11 opened this issue Oct 25, 2021 · 2 comments
Closed

what about variable block size? #2

menzi11 opened this issue Oct 25, 2021 · 2 comments

Comments

@menzi11
Copy link

menzi11 commented Oct 25, 2021

in audio processing callback, there is no guarantee that every callback has same block size, but I looked into the code I think oversimple can not handle variable block size. it assume every callback has same block size.

@unevens
Copy link
Owner

unevens commented Oct 27, 2021

hi. no, there are overloads that take the number of input samples aka the block size

for example the iir upsampler has

      /**
       * Up-samples the input.
       * @param input a pointer to the memory holding the input samples
       * @param numInputSamples the number of samples in each channel of the input
       * buffer
       * @param output an InterleavedBuffer to hold the up-sampled samples
       * @param numChannelsToProcess the number of channels to process. If negative,
       * all channels will be processed.
       */
      void processBlock(Scalar* const* inputs,
                        uint32_t numInputSamples,
                        InterleavedBuffer<Scalar>& output,
                        int numChannelsToProcess)

dor the iir downsampler

      /**
       * Down-samples the input.
       * @param input an InterleavedBuffer holding the input
       * @param numSamples the number of samples in each channel of the input
       * buffer
       * @param numChannelsToProcess the number of channels to process. If negative,
       * all channels will be processed.
       */
      void processBlock(InterleavedBuffer<Scalar> const& input, uint32_t numSamples, int numChannelsToProcess)

the fir upsampler

      /**
       * Up-samples a multi channel input buffer.
       * @param input pointer to the input buffer.
       * @param numChannels number of channels of the input buffer
       * @param numSamples the number of samples of each channel of the input
       * buffer.
       * @return number of upsampled samples
       */
      uint32_t processBlock(double* const* input, uint32_t numChannels, uint32_t numSamples);

the fir downsampler

      /**
       * Down-samples a multi channel input buffer.
       * @param input pointer to the input buffers.
       * @param output pointer to the memory in which to store the downsampled data.
       * @param numOutputChannels number of channels of the output buffer
       * @param requiredSamples the number of samples needed as output
       */
      void processBlock(double* const* input,
                        uint32_t numSamples,
                        double** output,
                        uint32_t numOutputChannels,
                        uint32_t requiredSamples);

@unevens
Copy link
Owner

unevens commented Oct 27, 2021

also, the methods that don't take the number of samples as an argument, retrieve it from the buffer object, as in

      /**
       * Up-samples a multi channel input buffer.
       * @param input ScalarBuffer that holds the input buffer.
       * @return number of upsampled samples
       */
      uint32_t processBlock(ScalarBuffer<float> const& input)
      {
        return processBlock(input.get(), input.getNumChannels(), input.getNumSamples());
      }

the maximum size of the block must be set by calling the prepareBuffers method, which will allocate the necessary resources. in the context of an audio plugin you can do that in the methods like vst3's setupProcessing or setActive.

@unevens unevens closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants