Box behaving differently in different situations

Concerning processing components: filters, file load/save, visualizations, communication ...
lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Box behaving differently in different situations

Post by lbonnet »

Hi Karthik,
Sorry for late reply!

The source code:

Code: Select all

 if(*l_pBuffer > m_f64Threshold && !m_bTriggerActive)
{
Just to be sure... Note that this test only compare the very first value in the input buffer with the threshold.

Here is what we can extract from the log.

> I can see that the output stream of your box is a streamed matrix, 1x500 values.

Code: Select all

[name:OVTK_NodeId_Header_StreamedMatrix_DimmensionCount]-[type:uinteger]-[value:2]
...
[name:OVTK_NodeId_Header_StreamedMatrix_Dimmension_Size]-[type:uinteger]-[value:1]
...
[name:OVTK_NodeId_Header_StreamedMatrix_Dimmension_Size]-[type:uinteger]-[value:500]
> Before receiving the stimulation OVTK_StimulationId_Label_00, the box sends empty chunks.
Example :

Code: Select all

[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy> For input Spied EBML stream 1 of type EBML stream :
[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000001, 0xcb000000),(0x00000002, 0xcb000000)]
[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy>
> Is it really necessary ?

> Near 3 seconds, it receives the stimulation

Code: Select all

[  INF  ] At time 3.094 sec <Box algorithm::Stimulation listener> For input 0 with name Stimulation stream 1 got stimulation 33024[OVTK_StimulationId_Label_00] at date 13287555072 and duration 0
NB :As the date of the stimulation is not printed in seconds, I suppose you don't have an up-to-date openvibe ;)

> Triggering the PCPG box:

Code: Select all

[  INF  ] At time 3.094 sec <Box algorithm::PCPG> Start stimulation received
> Then chunks of data are sent by the box :

Code: Select all

[  INF  ] At time 3.094 sec <Box algorithm::PCPG> Start stimulation received 
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy> 
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy> For input Spied EBML stream 1 of type EBML stream :
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000001, 0xfe000000),(0x00000002, 0xfe000000)]
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy>   Opened EBML node [id:(0x00cf2101, 0x02375310)]-[name:OVTK_NodeId_Buffer]
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy>     Opened EBML node [id:(0x00120663, 0x08fbc165)]-[name:OVTK_NodeId_Buffer_StreamedMatrix]
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy>       Opened EBML node [id:(0x00b18c10, 0x427d098c)]-[name:OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer]-[type:binary]-[bytes:4000]
[  INF  ] At time 3.094 sec <Box algorithm::EBML stream spy>
> 4000 bytes per buffer (1x500 float64). Ok.

> The chunk dates tells me that your output stream is not continuous. For example :

Code: Select all

[  INF  ] At time 4.781 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xaf800000),(0x00000004, 0xaf800000)]
...
[  INF  ] At time 4.906 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xc9000000),(0x00000004, 0xc9000000)]
...
[  INF  ] At time 5.031 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xe2800000),(0x00000004, 0xe2800000)]

Time values (64bits) are written in hexa; 32 bits for the seconds, 32 bits for the divisors.
This means that all chunks represent 1 seconds, but not on a continuous stream.
Is it normal regarding what you want to output ?

To conclude, please tell us :
- what are the inputs of the PCPG box (stimulation + signal, am I wrong ?)
- Do you implement the processClock function or the processInput function in the box ?
- When do you need to process an output ? Do you need a specific amount of samples ? or on a regular clock tick ?
- Is it necessary to output empty chunks before the trigger ?
- What is the "timing" of the output stream ? The stream must be continuous or not ?

Sorry, it's a lot of question, some of them you already answered maybe...
I admit I have some trouble understanding the full picture here, so I want to make things clear :)



Laurent-
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

karthiks
Posts: 78
Joined: Thu Sep 02, 2010 2:43 pm
Location: Université Libre de Bruxelles

Re: Box behaving differently in different situations

Post by karthiks »

lbonnet wrote: Sorry for late reply!
Thank you for the reply :D
lbonnet wrote: The source code:

Code: Select all

 if(*l_pBuffer > m_f64Threshold && !m_bTriggerActive)
{
Just to be sure... Note that this test only compare the very first value in the input buffer with the threshold.
Err that means I have done something wrong here. I want it to compare the buffer against the threshold. Not just the first element. But still this is ok.
lbonnet wrote: > Before receiving the stimulation OVTK_StimulationId_Label_00, the box sends empty chunks.
Example :

Code: Select all

[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy> For input Spied EBML stream 1 of type EBML stream :
[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000001, 0xcb000000),(0x00000002, 0xcb000000)]
[  INF  ] At time 2.906 sec <Box algorithm::EBML stream spy>
> Is it really necessary ?
Again something weird as it is only supposed to send signals once it is triggered.
lbonnet wrote: NB :As the date of the stimulation is not printed in seconds, I suppose you don't have an up-to-date openvibe ;)
I checked out the latest and compiled. Think it is 0.13.1? I dunno why it is still not ok.
lbonnet wrote: > The chunk dates tells me that your output stream is not continuous. For example :

Code: Select all

[  INF  ] At time 4.781 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xaf800000),(0x00000004, 0xaf800000)]
...
[  INF  ] At time 4.906 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xc9000000),(0x00000004, 0xc9000000)]
...
[  INF  ] At time 5.031 sec <Box algorithm::EBML stream spy> For chunk [id:0] at [time:(0x00000003, 0xe2800000),(0x00000004, 0xe2800000)]

Time values (64bits) are written in hexa; 32 bits for the seconds, 32 bits for the divisors.
This means that all chunks represent 1 seconds, but not on a continuous stream.
Is it normal regarding what you want to output ?
It should be continuous. :(
lbonnet wrote: To conclude, please tell us :
- what are the inputs of the PCPG box (stimulation + signal, am I wrong ?)
The input is stimulation.
lbonnet wrote: - Do you implement the processClock function or the processInput function in the box ?
ProcessInput.
lbonnet wrote: - When do you need to process an output ? Do you need a specific amount of samples ? or on a regular clock tick ?
When I get the start stimulation, the box is supposed to send a stream of data which is generated based on equations written in the box.
lbonnet wrote: - Is it necessary to output empty chunks before the trigger ?
No, it should not be happening
lbonnet wrote: - What is the "timing" of the output stream ? The stream must be continuous or not ?
The stream must be continuous.
lbonnet wrote: Sorry, it's a lot of question, some of them you already answered maybe...
I admit I have some trouble understanding the full picture here, so I want to make things clear :)
Thank you for taking time.

Btw, I have since moved the code outside OpenViBE. So, it is not a priority. This is just a learning exercise for me now.
Regards,

Karthik

karthiks
Posts: 78
Joined: Thu Sep 02, 2010 2:43 pm
Location: Université Libre de Bruxelles

Re: Box behaving differently in different situations

Post by karthiks »

As I said in the previous post, that PCPG box is not a priority for me.

I have run in to a different kind of problem, very similar in nature to this one but different in reason I am sure. I have attached a code of a box that I am using. It is a modification on the Sinus Signal Generator.

Before the introduction of the stimulation trigger, the box was working fine. Now it is extremely slow. Is it just because of the loops?

Code: Select all

boolean CSinusSignalGenerator::process(void)
{
	IBoxIO* l_pDynamicBoxContext=getBoxAlgorithmContext()->getDynamicBoxContext();

	for (uint32 i=0; i<l_pDynamicBoxContext->getInputChunkCount(0); i++)
	{
		m_oStimulationDecoder.decode(0,i);

		if (m_oStimulationDecoder.isHeaderReceived())
		{
			uint32 j;
			if(!m_bHeaderSent)
			{
				m_pSignalOutputWriterHelper->setSamplingRate(m_ui32SamplingFrequency);
				m_pSignalOutputWriterHelper->setChannelCount(m_ui32ChannelCount);
				m_pSignalOutputWriterHelper->setSampleCountPerBuffer(m_ui32GeneratedEpochSampleCount);
				m_pSignalOutputWriterHelper->setSampleBuffer(m_pSampleBuffer);
				for(j=0; j<m_ui32ChannelCount; j++)
				{
					char l_sChannelName[1024];
					sprintf(l_sChannelName, "Channel %i", (int)j);
					m_pSignalOutputWriterHelper->setChannelName(j, l_sChannelName);
				}
				m_pSignalOutputWriterHelper->writeHeader(*m_pSignalOutputWriter);
				m_bHeaderSent=true;

				uint64 l_ui64Time=(((uint64)(m_ui32SentSampleCount))<<32)/m_ui32SamplingFrequency;
				l_pDynamicBoxContext->markOutputAsReadyToSend(0, l_ui64Time, l_ui64Time);
			}
		}
		if (m_oStimulationDecoder.isBufferReceived())
		{
			IStimulationSet* l_pStimulations = m_oStimulationDecoder.getOutputStimulationSet();
			for(uint32 j=0; j<l_pStimulations->getStimulationCount(); j++)
			{
				if (l_pStimulations->getStimulationIdentifier(j) == m_ui64StartTrigger)
				{
					m_bGenerate = true;
					this->getLogManager() <<LogLevel_Info << "Start stimulation received \n";
				}
				else
				{
					if (l_pStimulations->getStimulationIdentifier(j) == m_ui64StopTrigger)
					{
						m_bGenerate = false;
						this->getLogManager() <<LogLevel_Info << "Stop stimulation received \n";
					}
				}
			}
		}

		if(m_bGenerate)
		{
			uint32 j;
			uint32 l_ui32SentSampleCount=m_ui32SentSampleCount;

			j = 0;
			m_pSampleBuffer[j]= sin (2*3.1416*0.9498*time_counter);

			j = 1;
			m_pSampleBuffer[j]= sin (2*3.1416*(1-0.9498*time_counter));

			j = 2;
			m_pSampleBuffer[j]= sin (2*3.1416*1.9*time_counter);

			j = 3;
			m_pSampleBuffer[j]= sin (2*3.1416*(1-1.9*time_counter));

			j = 4;
			m_pSampleBuffer[j]= sin (2*3.1416*2.849*time_counter);

			j = 5;
			m_pSampleBuffer[j]= sin (2*3.1416*(1-2.849*time_counter));

			j = 6;
			m_pSampleBuffer[j]= sin (2*3.1416*3.799*time_counter);

			j = 7;
			m_pSampleBuffer[j]= sin (2*3.1416*(1-3.799*time_counter));

			j = 8;
			m_pSampleBuffer[j]= sin (2*3.1416*4.749*time_counter);

			j = 9;
			m_pSampleBuffer[j]= sin (2*3.1416*(1-4.749*time_counter));


			time_counter = time_counter + 0.01;

			m_pSignalOutputWriterHelper->writeBuffer(*m_pSignalOutputWriter);
			m_ui32SentSampleCount+=m_ui32GeneratedEpochSampleCount;

			uint64 l_ui64StartTime;
			uint64 l_ui64EndTime;
			l_ui64StartTime=(((uint64)(l_ui32SentSampleCount))<<32)/m_ui32SamplingFrequency;
			l_ui64EndTime  =(((uint64)(m_ui32SentSampleCount))<<32)/m_ui32SamplingFrequency;
			l_pDynamicBoxContext->markOutputAsReadyToSend(0, l_ui64StartTime, l_ui64EndTime);
		}
	}

	return true;
}
Regards,

Karthik

Post Reply