ASPiK SDK
|
With the object designed and the ICustomView interface implemented, you can turn your attention to the plugingui.cpp file. The function that is called to give the object the first opportunity to create a custom view is named createView( ):
The attributes and description arguments come from the GUI class factory that calls the method and contains all the information gleaned from the XML description file. One piece of that information is the custom view name, which is what we use to decode the data and instantiate the view. We’ve already setup a secondary function createUserCustomView( ) that will do some of the decoding work for you. You may either append your custom views to that function, or modify the function above. In the case of the waveform and spectrum views we’ll use the secondary function. For other controls, you will need to work inside of createView( ) where you can have access to all of the attribute and description information. You can see that this function is simple - we just decode the name string and then create a new object.
The part of createView that calls this function is shown here. This is where the ICustomView pointer is obtained from the newly created object and safely sent to the plugin shell using the IGUIPluginConnector interface pointer that it obtained during its creation:
The next step is to pick up these pointers when the native plugin shell registers them with the plugin core object. This is done in the plugincore.cpp file inside of the PluginCore::processMessage( ) which handles GUI events from the native plugin shell (don't worry, this is thread-safe). There are numerous messages that are decoded in this function, but we only need to deal with a couple of them:
PLUGINGUI_REGISTER_CUSTOMVIEW: this message is sent once per custom view, each time the GUI is opened. Once you have stored a custom view interface pointer, you don't need to ever re-copy or re-store it. However this function WILL be called when the GUI is opened so you can use it (in part) to know a bit about the lifecycle of the GUI.
PLUGINGUI_TIMERPING: this message is sent on every GUI update interval (50 msec) and is called from the GUI thread. This is where we will feed audio samples into the custom views and call the methods to update (repaint) these windows. Since this function is called from the GUI thread, we need that lock-free ring buffer on our plugin side to hold audio data from the audio processing thread.
To pick up and store the interface pointers, you modify the code for the PLUGINGUI_REGISTER_CUSTOMVIEW to decode the incoming name string and store the pointer. This code is just for the two custom audio viewers; we'll address the custom knob later. User the example below to see how the pointers are passed into the message system - make sure you understand this if you want to modify it for your own custom messaging or other uses.