- NB: Document updated for OpenViBE 1.0.0 (05.Jun.2015).
What ?
We want a box to send a signal in its output, but there is no signal input to base our stream on.
References
Code
We assume:
m_oSignalEncoder
is a Stimulation encoder from the codec toolkitm_bHeaderSent
is a boolean member indicating if the stream header has been sent already or not (set to false ininitialize()
)- The signal output is at index 0 in the box and the encoder has been initialized to this output.
l_ui64LastChunkEndTime
is the last end time of the previous chunk.- The box implements
processClock
, and the box clock frequency is 128Hz.
In the process()
function of your box:
IMatrix *l_pInputMatrix = m_oAlgo0_SignalEncoder.getInputMatrix(); if(!m_bHeaderSent) { m_oAlgo0_SignalEncoder.getInputSamplingRate() = 512; // we build a 512Hz signal. l_pInputMatrix->setDimensionCount(2); // 2 dimensions : channels X samples l_pInputMatrix->setDimensionSize(0,2); // 1st dimension is the channel count, let's say 2 l_pInputMatrix->setDimensionSize(1,4); // 2nd dimension is the number of samples per block. // As we want a 512Hz signal if the box clock frequency is 128Hz, we need 4 samples per block. l_pInputMatrix->setDimensionLabel(0,1,"channel 1"); // on the first dimension l_pInputMatrix->setDimensionLabel(0,2,"channel 2"); // the channels can be named m_oAlgo0_SignalEncoder.encodeHeader(); m_bHeaderSent = true; } else { for(uint32 i = 0; i < l_pInputMatrix->getBufferElementCount(); i++) { l_pInputMatrix->getBuffer()[i] = i; // for example... } m_oAlgo0_SignalEncoder.encodeBuffer(); } // we send the new chunk anyway uint64 l_ui64ChunkEndTime = this->getPlayerContext().getCurrentTime(); this->getDynamicBoxContext().markOutputAsReadyToSend(0, m_ui64LastChunkEndTime, l_ui64ChunkEndTime); m_ui64LastChunkEndTime = l_ui64ChunkEndTime;