This article is about creating a module or box in OpenViBE by using Skeleton Generator. Skeleton generator is a nice application for .h and .cpp file generating which specially designed for OpenViBE by OpenViBE team.
OpenViBE itself has some predefined variable type and functions which you can see most of them inside all modules .h and .cpp files. These variables and functions help the core application of OpenViBE to recognize the behavior of the modules. In this purpose, they provide skeleton generator to create the necessary functions and variables for specific module. On the way of explaining the procedure of module creation, we are going to create a module for calculating Momentary Frequency Module.
Open the OpenViBE folder >> dist >> double click on “ov-skeleton-generator.cmd”. The “OpenViBE Skeleton-Generator” will show up.
There are two radio box “Driver skeleton” and “Box skeleton”, by default the “Driver skeleton” is checked, click on “Box skeleton”, because we do not want to create any driver (there are some devices which OpenViBE cannot connect and reads data from them, in that purpose you can use Driver skeleton to create drivers to connect and read data for specific devices). In the “Author” and “Company“ text boxes write the information which you want to show up about your module, then click on “OK” button. In the next window, there are seven tabs correspond to module information and behavior.
This tab is for module/box name, class name in .h and .cpp file, version of box, category which the module belongs and will show up in the designer, short and detailed description of the module/box and at the end icon of the box.
In this tab, we chose how many and what type of inputs does the box need. In case of Momentary frequency, it needs one input with type of signal. Click on the “Add” button and add one input with name “Signal” and type “signal”. There are two check boxes in this tab, for this module, there is no need to any modification or add/remove option for user, uncheck both of them.
This tab is about the output of the box, Momentary frequency has one output with type of signal, so, click on “Add” button and add one output with name “Momentary Signal” and type “signal”. In case of output also the module doesn’t need to be edit, add or remove, uncheck both check boxes.
If you already have started to explore the existed modules in designer, perhaps you see that some of boxes have some setting like necessary coefficients or address of file to be read or right. Momentary frequency has two setting value, Adaptation time for the mean estimator and frequency estimator. Add two setting by names of “AdapTime_FreqEstimation” and “AdapTime_MeanEstimation” with type “Float” and Default value “0.002” and uncheck the both check boxes too.
Codec Algorithm Tab:
Codec Algorithm tab is the place to add predefined functions which provided by OpenViBE team. Here, we add two functions “Signal stream decoder” and ”Signal stream encoder”. OpenViBE defined a special “signal” variable which contains a batch of information about signal data. In Momentary Frequency, we want to work on signal data, so, we use the “Signal stream decoder” to extract the part which we need for Momentary frequency calculation and put it inside another special variable “Matrix”. By “Matrix” we can access to necessary data directly. Because, the output of Momentary frequency is a type “signal” again, we add a “Signal stream encoder” to encode calculated data into a “signal”type. In this tab it recommended to use codec toolkit, let the check box be checked.
Processing Method Tab:
In this tab, we define how the module will call by OpenViBE core application. As you can see, there are two check boxes, for Momentary frequency, it needs to be called for all chunk of input (OpenViBE sends data as input by blocks/chunks of data, each chunk contains 32 values of signal data), so, click on the first check box to be check. The second check box is about calling the module in case of specific frequency, in this module, it doesn’t need this option, let it be unchecked.
Box Listener Tab:
By this tab, you can define a Box Listener for the module; they will run just in case their condition be true, their statement could be modified inside the code of module. For Momentary frequency, it doesn’t need any Box Listener, let them all be inactive.
At this moment we are ready to check and then generate the code of Momentary frequency module/box. Click on the “Check” button. You should see the following information at the bottom of Skeleton Generator window:
At the end, click on “Generate” button to generate the code. In the “Select the destination folder” window, go to the OpenViBE folder >> openvibe-plugins >> signal-processing-gpl >> trunk >> src and click on “OK” button. This address is the location which we want the module code be generate be compile.
If you check the given address, you can see that the “ovpCBoxAlgorithmMomentaryFrequency.h” and “ovpCBoxAlgorithmMomentaryFrequency.cpp” files are generated.