Hi, I am creating a Audio Plug in which will read a file from the path specified by the user and puts the data in the buffer.
I am using the plug in host application for loading this DLL.
I want to run the process block of my plug in as the same sample rate as that of opened file. But I am not able to do it
Example:
Currently sample rate given by the device is 44100hz and block size is 441.
My test file is 32000Hz. I want the process block to be called at the rate of 32000 ( sample rate of the wav file i loaded).
host means the device or the plug in host?
I am guessing that 44100 is coming from the device rather than host?
It picks the default sample rate of the device and sets in to the plg in graph. Am I right?
Ok If I have to re-sample the Audio how can I do it?
If I create a Plug-in for resampling the data, still the processBlock of the resampling plug in is called at 44100Hz.
The resampled data wont be in required 32000Hz reight?
Your plugin is required to deliver the sample data sampled with the frequency your host is operating on, in your case 44100 Samples/sec.
If your plugin is not using the data coming from the host but creates (or loads) sample data, it is your / your plugins responsibility to take care of, that the data is in the right sample rate. You donât have to do anything, but then your sound is played back with the wrong speed, sounds like mickey mouse.
So read a block of data, which is shorter by 44100/32000 and resample (=interpolate) it to fill one buffer. This is the data your plugin puts into the AudioBuffer of processBlock.
To resample you can use the LagrangeInterpolator patrickkunz proposed, or you check out the ResamplingAudioSource, as you use the AudioSource for reading anywayâŠ
I never heard of decimate in that context, but if you mean you simply drop samples, than consider that this might not improve sound qualityâŠ
And furthermore if you want to play back 32kHz PCM data with a 44.1kHz sound device, you donât need less samples but more. This is why resampling is the right approach for youâŠ
I think you can use the interpolator for down and upsampling. You maybe need to pre-filter the signal before you interpolate if you want good quality. You donât know the host sample rate and simple decimation only with pre-filtering maybe donât lead to good results if you have odd ratios.
It sounds to me, that you are actually not creating a plugin but rather some sort of custom host?
There is something called AudioProcessorGraph. Here you can combine several steps of processing. But I didnât use that, so maybe somebody else should chime in, if you have questions how to use it.
But to explain: the application that is feeding the AudioDevice operates with exactly one sample rate. everything else needs to process itâs data so that the produced output matches the deviceâs setup.
Usually the host picks up that speed and expects all itâs plugins to deliver itâs output in that sample rate. So you should design your processing that it can cope with that, e.g. by resampling itâs audiodata.
BTW. usually a plugin picks up the audio data from the host, so the host has already resampled the data for you.
If you deliver audio data from other sources, then you are creating a synth?