To better understand mecanism and logic of boxes, I took the meanVariance box example. It is linked to this document if you don't have [plugins\sample]. Some Part are still incomplet (in red), that why I post :
LE .H
_The CBox... class CBox inherit the well done plugin :
Code: Select all
class CBoxAlgorithmMeanVariance : public OpenViBEToolkit::TBoxAlgorithm<OpenVibe::Plugins::IBoxAlgorithm > {...};
Code: Select all
virtual void release() ..., virtual OpenViBE::boolean initialize(), virtual OpenViBE::boolean uninitialize(), virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex), virtual OpenViBE::boolean process() ... and some other methods
After, as protected, some parameters are buildt, and proxy for in/output
Code: Select all
OpenViBE::Kernel::IAlgorithmProxy *m_p...
Code: Select all
OpenViBE::Kernel::TParameterHandler<OpenViBE::IMemoryBuffer*>
_The CBox_Desc.... class inherit IBoxAlgorithmDesc
Then,the standard virtual methods which begin with get_...(name), next getCreatedClass, create and getBoxPrototype which define the BoxContext.
And endly the well done macro: _IDerivedFromClass_Final(....)
up to here, all seems to be ok, it is easy to follow (if the macro is accepted).
LE .CPP
initialize()
The three proxy have been instantiated with an algorithm from a list:
Code: Select all
(*3) Decoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(REF_Algo));
Decoder->initialize()
Code: Select all
EBMLMemHandle.initialize(decoder->getInputParameter(Ref))
Code: Select all
getStaticBoxContext().getSettingValue(0,m_sDSPConfigurationFilename);
getStaticBoxContext().getSettingValue(1,m_sMinMaxConfigurationFilename);
...
uninitialize()
...in the same manner ...
processInput()
box is marked as ready ti process data
process()
Retrievement of matrix in box context:
Code: Select all
IBoxIO& l_r_Dyn...=this->getDynamicBoxContext()
Code: Select all
for(uint32 j=0; j<l_rDynamicBoxContext.getInputChunkCount(0); j++
Code: Select all
m_oEBMLMemoryBufferHandleInput1=l_rDynamicBoxContext.getInputChunk(0,j); //...more start and End Time
Code: Select all
if(m_pDecoderInput1->isOutputTriggerActive(Ref_Header)) ...
//...
if(m_pDecoderInput1->isOutputTriggerActive(Ref_Buffer)
//...
to force output matrix to be of on two dimension??
Code: Select all
m_oMatrixOutput1Handle->setDimensionCount(2);
m_oMatrixOutput2Handle->setDimensionCount(2)
Code: Select all
m_ui32NbChannels=m_oMatrixInput1Handle->getDimensionSize(0);
m_ui32NbSamplesPerBuffer=m_oMatrixInput1Handle->getDimensionSize(1);
Code: Select all
m_f64S1List.resize(m_ui32NbChannels);
m_f64S2List.resize(m_ui32NbChannels);
m_f64N=0
Code: Select all
for(uint32 i=0; i<m_oMatrixInput1Handle->getDimensionCount();i++)//....
Code: Select all
m_oMatrixOutput1Handle->setDimensionSize(0,m_ui32NbChannels);
m_oMatrixOutput1Handle->setDimensionSize(1,1);
Code: Select all
m_oEBMLMemoryBufferHandleOutput1=l_rDynamicBoxContext.getOutpuutChunk(0)
if time disable process, write messages in a file and go on.
else :
dump data in handlers :
Code: Select all
float64* l_pBufferInput1=m_oMatrixInput1Handle->getBuffer();
Code: Select all
uint32 l_ui32Offset=0;
for(uint32 i=0; i<m_ui32NbChannels; i++){
for(uint32 j=0; j<m_ui32NbSamplesPerBuffer; j++){
//...raise S1, S2
}
}
//raise N
//calculate mean and variance
Code: Select all
m_oEBMLMemoryBufferHandleOutput1=l_rDynamicBoxContext.getOutputChunk(0); //...
Code: Select all
l_rDynamicBoxContext.markInputAsDeprecated(0,j);