OpenViBE forum

The OpenViBE community
It is currently Sat Dec 16, 2017 8:26 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Dec 23, 2015 12:18 am 
Offline

Joined: Wed Apr 11, 2012 1:31 pm
Posts: 36
Location: Nice - Alpes Maritimes
Hi there
Is there a way to delay signals (by a number of samples or ms) or is there a way to implement it (via a FIR filter ?) in the designer ? I am looking for a way to implement easily a CSSP or CSSSP method.
Jeff


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 27, 2015 2:35 pm 
Offline

Joined: Wed Apr 11, 2012 1:31 pm
Posts: 36
Location: Nice - Alpes Maritimes
Hi Openvibers,
I am not an experimented user of OV (just managed to compile it with an exotic driver) but I guess I will have to make a basic signal processing box to augment the regular (current or non delayed) signal flow with delayed versions of it. It would have two parameters (order and base_delay) and would augment the signal flow buffer this way:

channel 0 samples - channel 1 samples - .... - channel N samples - channel 0 samples delayed by base_delay - ..... - channel N samples delayed by base_delay - channel 0 samples delayed by 2*base_delay - ..... - channel N samples delayed by 2*base_delay - .............. - channel 0 samples delayed by order*base_delay - ..... - channel N samples delayed by order*base_delay

My original intend is to build a classifier for cursor control using a bank of spatio frequential filters built via CSP followed by a SVM. To include this frequential dimension in the CSP (FIR filtering), I was thinking to create new (virtual) channels with time delayed versions of the existing ones, and to deal with them in the same way we process the spatial samples using the regularized version of the CSP. A CSP filtered signal would thus be a linear combination of both spatial samples (spatial filtering) and their time delayed versions (temporal/frequential filtering). This brings a question about this regularized CSP: is there a way to apply a different amount of regularization /whitenning for the varied channels (enabling me to apply a different amount of regularization accross spatial (0-lagged) or temporal/frequential (lagged) dimensions ?). Or should I have to modify it ? o.O
Have a pleasing solstice and a gratifying ew year of research,
Jean-François B.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 28, 2015 4:46 pm 
Offline

Joined: Wed Apr 11, 2012 1:31 pm
Posts: 36
Location: Nice - Alpes Maritimes
Hi there,
I have implemented this DelayLines as a basic signal processing box (see attached files).

It compiles but keep crashing if played under the designer with a sinus generator as input, ending in a C0000005 error code.

The problem seems linked to fifo_buffer, since when I comment out the lines where I use the fifo_buffer in the implementation of CBoxAlgorithmDelayLines::process():

Code:
for(uint32 i = 0 ; i < m_ui64channel_count ; i++)
{
   for(uint32 j = 0 ; j < m_ui64max_sample ; j++)
   {
      fifo_buffer[j + m_ui64sample_count + i*m_ui64sample_fifo] = fifo_buffer[j + i*m_ui64sample_fifo];
      if(j < m_ui64sample_count)
         fifo_buffer[j + i*m_ui64sample_fifo] = l_pBuffer[m_ui64sample_count - 1 - j + i*m_ui64sample_count];
   }
}


... the box can be played without any crash/unhandled exception (even if it does not produce any meaninful values).

I can write into fifo_buffer using for exemple: fifo_buffer[m_ui64sample_fifo]=1.0; but I cannot use for exemple:
Code:
for(int i=0; i<m_ui64sample_fifo; i++)
{
      fifo_buffer[i]=1.0;
}


fifo_buffer is a private attribute of the CBoxAlgorithmDelayLines class, and declared as:
Quote:
OpenViBE::float64 *fifo_buffer;

I have tried to dynamically allocate it in the CBoxAlgorithmDelayLines::initialize() via:
Code:
fifo_buffer = new OpenViBE::float64[m_ui64channel_count*m_ui64sample_fifo];
or
     std::vector<OpenViBE::float64> fifo_buffer(m_ui64channel_count*m_ui64sample_fifo, 0);
or
     fifo_buffer = (OpenViBE::float64 *) calloc(m_ui64channel_count*m_ui64sample_fifo, sizeof(OpenViBE::float64));

followed (not in the case of std::vector) by
Code:
memset(fifo_buffer, 0, sizeof(OpenViBE::float64)*m_ui64channel_count*m_ui64sample_fifo);

... without much success (always this C0000005 error code).

Any idea guys ? I am really stuck with this !
Best,
Jeff


Attachments:
ovpCBoxAlgorithmDelayLines.cpp [7.32 KiB]
Downloaded 156 times
ovpCBoxAlgorithmDelayLines.h [6.25 KiB]
Downloaded 154 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 29, 2015 5:58 am 
Offline

Joined: Wed Apr 11, 2012 1:31 pm
Posts: 36
Location: Nice - Alpes Maritimes
The box works properly with a fixed (large) size array for fifo_buffer. Any clue about the reason why the dynamic allocation fails ?
Jeff


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 04, 2016 12:05 pm 
Offline

Joined: Tue Dec 04, 2012 3:53 pm
Posts: 601
Location: INRIA Rennes, FRANCE
Hello Jeff,

welcome on board and thanks for the detailed report! The reason for the crash is clear from the source code. The thing is that the size of the matrix is information that is passed from box to another *during* the processing, in a specific 'header' segment, usually sent as the very first chunk of the stream. You need to allocate your buffer inside this block in process(),

Code:
if(m_oInput0Decoder.isHeaderReceived())
{
   // ...
}


if you do it in initialize(), the decoder does not yet know what the actual sizes are.

About the other things, I think you're right, there's no explicit delay box in OV at the moment. About the CSP, you can't do per-channel regularization without modifying the box, but you might try learning two differently regularized CSP filters altogether by splitting the signal with Channel Selector -- although this might hamper your original purpose. :)

Good luck,
Jussi


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 19, 2016 5:28 pm 
Offline

Joined: Wed Apr 11, 2012 1:31 pm
Posts: 36
Location: Nice - Alpes Maritimes
Hum... after the 1st header is received is far better... of course, thank you Jussi :mrgreen: :arrow:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maël Soucaze.