I want to do my project using openvibe and another software.
i made a connection between these two software.
in OpenVibe we have a sign change detector which it send a stimuli to my another software but the problem is
i don't know how can i send a unit8 output.
in my project i should read EEG beta band power if this power is higher than my threshold send 1 and if lower than threshold send 0.
here a i have a simple Matlab code that it work well for sending 1 or 0 but i don't know how can i write in C++ language.
Go=uint8('1');
Stop=uint8('0');
hudps = dsp.UDPSender('RemoteIPPort',3000); % Sets up UDP Sender port
if(BetaValue>0.2) % My Threshold
hudps(Go);
else
hudps(Stop);
end
m_ui64ChannelIndex=FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2);
if (m_ui64ChannelIndex == 0)
{
this->getLogManager() << LogLevel_Info << "Channel Index is 0. The channel indexing convention starts from 1.\n";
return false;
}
m_ui64ChannelIndex--; // Convert from [1,n] indexing to [0,n-1] indexing used later
// Get a few convenience handles
const OpenViBE::IMatrix* l_pMatrix = m_oStreamedMatrixDecoder.getOutputMatrix();
OpenViBE::IStimulationSet* l_pStimulationSet = m_oStimulationEncoder.getInputStimulationSet();
// We decode the stream matrix
for(uint32 i=0; i<l_rDynamicBoxContext.getInputChunkCount(0); i++)
{
const uint64 l_ui64StartTime=l_rDynamicBoxContext.getInputChunkStartTime(0, i);
const uint64 l_ui64EndTime=l_rDynamicBoxContext.getInputChunkEndTime(0, i);
m_oStreamedMatrixDecoder.decode(i);
// if we received the header
if(m_oStreamedMatrixDecoder.isHeaderReceived())
{
//we analyse the header (meaning the input matrix size)
if (l_pMatrix->getDimensionCount() != 2)
{
this->getLogManager() << LogLevel_ImportantWarning << "Streamed matrix must have exactly 2 dimensions\n";
return false;
}
else
{
if (m_ui64ChannelIndex >= l_pMatrix->getDimensionSize(0))
{
this->getLogManager() << LogLevel_Info << "Channel Index out of bounds. Incoming matrix has fewer channels than specified index.\n";
return false;
}
// we send a header on the stimulation output:
m_oStimulationEncoder.encodeHeader();
l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_ui64StartTime,l_ui64EndTime );
}
// if we received a buffer
if(m_oStreamedMatrixDecoder.isBufferReceived())
{
l_pStimulationSet->clear();
const float64* l_pData = l_pMatrix->getBuffer();
// for each data sample of the buffer we look for sign change
// if we received the End
if(m_oStreamedMatrixDecoder.isEndReceived())
{
// we send the End signal to the stimulation output:
m_oStimulationEncoder.encodeEnd();
l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_ui64StartTime, l_ui64EndTime);
}
// The stream matrix chunk i has been processed
l_rDynamicBoxContext.markInputAsDeprecated(0, i);
}