|
How to manage custom DSP effects |
![]() ![]()
|
The purpose of custom DSP effects, implemented through a set of methods of the EffectsMan class, is to give the developer the possibility to apply DSP algorithms to the editing session: the concept of DSP effects is quite similar to the concept of Steinberg's Virtual Studio Technology (VST) effects but with some simplification and with more expansion possibilities.
As for VST effects, the main purpose of custom DSP effects is to take a stream of audio data, apply a process to the audio and return the result to the container application: as a secondary purpose, custom DSP effects can be used to perform sound analysis in real time, allowing for example the display of visual feedbacks or separation of stereo audio channels into different output files.
There are two types of custom DSP effects:
The code of these effects is inserted directly inside the code of the container application: usually the DSP code will be limited to a callback function containing the DSP algorithm and to some variable that will store parameters used by the DSP algorithm itself. In order to initialize an internal DSP effect, you need to create a unique identifier for the internal DSP effect: this task can be achieved through a call to the Effects.CustomDspInternalLoad method: the return value of this call will be a 32 bits value that will identify the internal DSP effect. At this point you need to set the callback function that will apply the DSP algorithm to incoming sound data: for this purpose you need to create a specific callback function inside your code and then to pass this function to Active Sound Editor calling the Effects.CustomDspInternalSetFunction method. It's important to remember that the algorithm of the DSP effect inside the callback function must be as quick as possible and should never call functions or APIs that could require user's interaction like message boxes and similar.
As for VST effects, the code of external DSP effects is inserted inside external dynamic-link library (DLL) files which need to export one or more pre-defined functions.
In order to initialize an external DSP effect, you need to create a unique identifier for the external DSP effect: this task can be achieved through a call to the Effects.CustomDspExternalLoad method which will receive the filename or the absolute pathname of the external DLL file and will return a 32 bits value that will identify the external DSP effect: this method can be considered a specialized version of the LoadLibrary Windows API. Once we have successfully loaded the external DSP and obtained its unique identifier, we can gain access to its exported functions through the Effects.CustomDspExternalSetFunction method which can be considered a specialized version of the GetProcAddress Windows API.
Functions exported by the dynamic-link library (DLL) containing the DSP effect should be one or more of the following:
It's certainly worth to mention that an external dynamic-link library (DLL) could contain more than one DSP effect: in this case, for each of the available DSP effects you will have to call the Effects.CustomDspExternalLoad method (this will obviously generate a specific unique identifier) and the Effects.CustomDspExternalSetFunction method for setting the specific callback function.
Both internal and external custom DSP effects can be discarded from memory using the Effects.CustomDspFree method.
In order to have a better understanding about the use and implementation of custom DSP effects, you will find some sample of usage of these internal and external DSP effects inside the SoundEditor sample installed by the product's setup package. You will also find two projects, written in Visual C++ 6, that demonstrate the implementation of two external custom DSP effects, one containing an editor (named MyCustomDspWithUI) that will implement a simple "Bass Boost" effect and one without any editor (named MyCustomDsp) that will implement two different effects: a simple "Reverb" effect and a simple "Balance" effect.
|