ASPiK SDK
|
Before getting into details about audio processing, we need to think about what happens after the user loads the plugin, but before audio data streams through it. One of the most important pieces of information we need is the current sample rate of the audio that will be processed through the plugin. Knowing the sample rate is critical for many of our calculations. This usually includes filter coefficients and delay-buffer sizes. The various API's each provide a mechanism for retrieving the current sample rate and this will depend on the API manufacturer. In some systems, the sample rate might change during the course of a DAW session and in others it must be locked down and set prior to the sessions creation. In all cases, the sample rate will not change while the audio is streaming into the plugin.
The PluginCore implements a reset function that is called during the plugin initialization, and then again any time the sample rate changes. It is also called in some APIs if the user stops and then restarts audio playback. There is some grey area here as well, based on how the DAW designers interpret the plugin API, or how the DAW itself operates and handles files with different sample rates. However, we can be sure that the reset function will be called at least once at initialization. You can find the reset function implementation in the plugincore.cpp file just below the initPluginParameters( ) function.
When you create your project, the function will have a default implementation shown here:
The reset function argument is a ResetInfo structure reference. This simple structure has only two members, one for the sample rate and one for the bit-depth. The bit-depth information is not available in all APIs, and is somewhat of a legacy attribute, dating back to the fixed-point processing days and early plugin APIs, so we will ignore it in our plugins here. However, if you are writing a plugin that needs to know if the audio file feeding it is 16-bit versus 24-bit and the API allows it, then you may use this information accordingly. You can see from the default implementation that the sample rate is stored on our audioProcDescriptor member variable, and you can access this value at any time and from any function in the core.
After storing the sample rate, your plugin may need to perform other resetting operations including: