Porting from ITimeArithmetics to CTime

Come here to discuss about OpenViBE in general!
Post Reply
toncho11
Posts: 124
Joined: Tue Apr 19, 2011 7:58 pm

Porting from ITimeArithmetics to CTime

Post by toncho11 »

Hi,

OV 3.0 replaced the ITimeArithmetics class with CTime.

I have this old code that coverts samples (positions in the signal represented by samples) to OV own representation of time:

Code: Select all

uint64_t l_ui64SampleStartTime = m_ui64StartTimeBase + ITimeArithmetics::sampleCountToTime(m_ui64OutputSamplingFrequency, m_ui64TotalSampleCount);
uint64_t l_ui64SampleEndTime = m_ui64StartTimeBase + ITimeArithmetics::sampleCountToTime(m_ui64OutputSamplingFrequency, m_ui64TotalSampleCount + m_ui32OutputSampleCountPerSentBlock);
So it uses the sampleCountToTime method. In the release notes of OV 3.0 (scroll down) it was not specified which was the equivalent in the new class CTime. I think it is the constructor of CTime. So I re-wrote the code like this:

Code: Select all

const uint64_t l_ui64SampleStartTime = CTime(m_ui64OutputSamplingFrequency, m_ui64TotalSampleCount).time();
const uint64_t l_ui64SampleEndTime =   CTime(m_ui64OutputSamplingFrequency, m_ui64TotalSampleCount + m_ui32OutputSampleCountPerSentBlock).time();
This is to show other users how I did it and maybe someone from the OV can comment/confirm.

Thomas
Posts: 211
Joined: Wed Mar 04, 2020 3:38 pm

Re: Porting from ITimeArithmetics to CTime

Post by Thomas »

Hi toncho11,

Thanks for you message and the clarification on this modification.

You are right with the equivalent use of CTime. For info, the CTime constructor is defined as follow:

Code: Select all

CTime(const uint64_t sampling, const uint64_t sampleCount);
CTime::time() then returns the time value in the usual OpenViBE 64 bits format.

This change was made in order to regroup all time related in functions in a class instead of calling static functions.

Cheers,
Thomas

Post Reply