OpenViBE forum

The OpenViBE community
It is currently Thu Dec 12, 2019 8:53 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jun 05, 2015 3:19 pm 

Joined: Sun Nov 23, 2014 5:32 am
Posts: 21
I have make the following editing on the averaging signal example in python tutorial, and I apply it on 3 channels with one input to the python scripting toolbox and one output , but it's always gives me that there is one input and one output, I conclude that we have to do channel localization and pass each channel to an input of the python toolbox, for example if i have 3 channels, then I should have 3 input signal to that toolbox and the same thing applies to the output of the toolbox, is that necessary?

the expected output of my code is to average each channel.

# we use numpy to compute the mean of an array of values
import numpy

 # let's define a new box class that inherits from OVBox
class MyOVBox(OVBox):
    def __init__(self):
    # we add a new member to save the signal header information we will receive
       self.signalHeader = None

    # The process method will be called by openvibe on every clock tick
    def process(self):
       # we iterate over all the input chunks in the input buffer
      x = len(self.input)
      print ("the size is ", x)
      for i in range(len(self.input)):
       for chunkIndex in range( len(self.input[i]) ):
          # if it's a header we save it and send the output header (same as input, except it has only one channel named 'Mean'
          if(type(self.input[i][chunkIndex]) == OVSignalHeader):
             self.signalHeader = self.input[i].pop()
             outputHeader = OVSignalHeader(
             [1, self.signalHeader.dimensionSizes[1]],

          # if it's a buffer we pop it and put it in a numpy array at the right dimensions
          # We compute the mean and add the buffer in the box output buffer
          elif(type(self.input[i][chunkIndex]) == OVSignalBuffer):
             chunk = self.input[i].pop()
             numpyBuffer = numpy.array(chunk).reshape(tuple(self.signalHeader.dimensionSizes))
             numpyBuffer = numpyBuffer.mean(axis=0)
             chunk = OVSignalBuffer(chunk.startTime, chunk.endTime, numpyBuffer.tolist())
          # if it's a end-of-stream we just forward that information to the output
          elif(type(self.input[i][chunkIndex]) == OVSignalEnd):

 # Finally, we notify openvibe that the box instance 'box' is now an instance of MyOVBox.
 # Don't forget that step !!
box = MyOVBox()

the output for the
print ("the size is ", x)
statement always gives me one , and the oscillator is generate 3 channels !,and I expect to have 3 element (or channels) in the
not one!

this my scenario and the configuration of sinus oscillator which is generate 3 channels
delete.png [ 18.86 KiB | Viewed 2040 times ]

My operating system is ubuntu 14.04 , using openViBE1.0.0

delete.png [ 31.47 KiB | Viewed 2040 times ]
Reply with quote  
PostPosted: Tue Jun 09, 2015 9:43 am 

Joined: Tue Apr 01, 2014 8:22 am
Posts: 71
You are confusing stream and stream structure.

You box have only one input, so self.input is size 1. For example, if the signal display was a python box, self.input would be equal to 3.

The channel is not a characteristic of the box, but of the stream. As you are using the signal type stream, the stream will have a fix structure (see It will be composed of a 2-dimensional matrix of size [N x M] with N the amount of channel, and M the amount of samples by channel.


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

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

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:  
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maƫl Soucaze.