Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Float to Array in Ruby

For general discussion related FlowStone

Float to Array in Ruby

Postby latour » Fri Aug 21, 2015 5:56 am

Hi all, this is my first post. I've discover Flowstone last year and i love it. I would like to thank all people on this forum sharing their knowledge.

I have found a lot of solutions here, but there's one i can't resolve: I use the "Float Array" module, works ok, but when there's a lot of data, display slow down. I've search all the forum and found there's some limitation on this module (I've read around 16000 data). I can't reduce data or speed for my usage so I need other solution than the "Float Array" module (need to store around 60000 data or more if possible). I think it is possible to store arrays in Ruby.

Is there a usable Ruby code to make this or ready Ruby module? (I'm not very good with Ruby). I need a reset/clear in, insert in, the last data must be first in the array, so just like the Float Array works.

Thank you very much for your aid.
latour
 
Posts: 6
Joined: Mon Sep 08, 2014 1:46 am

Re: Float to Array in Ruby

Postby tulamide » Fri Aug 21, 2015 3:52 pm

latour wrote:Hi all, this is my first post. I've discover Flowstone last year and i love it. I would like to thank all people on this forum sharing their knowledge.

I have found a lot of solutions here, but there's one i can't resolve: I use the "Float Array" module, works ok, but when there's a lot of data, display slow down. I've search all the forum and found there's some limitation on this module (I've read around 16000 data). I can't reduce data or speed for my usage so I need other solution than the "Float Array" module (need to store around 60000 data or more if possible). I think it is possible to store arrays in Ruby.

Is there a usable Ruby code to make this or ready Ruby module? (I'm not very good with Ruby). I need a reset/clear in, insert in, the last data must be first in the array, so just like the Float Array works.

Thank you very much for your aid.

Hi latour and welcome to the forums!

You're talking about a display slowing down. The float array has no display, so I assume you're connecting the float array out with the text prim? In that case you don't have an issue with the float array, but with the fact that the text prim will always have to convert the whole array to text. Always, with every change in the float array. And of course, converting 60000 floats to 60000 lines of text, plus the drawing of the text, takes a lot of time.

Could you elaborate on what your actual application for the float array is? I think, an optimized display of the data will have much more impact on performance than a Ruby version of the float array.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Float to Array in Ruby

Postby latour » Fri Aug 21, 2015 11:05 pm

Hi tulamide , thank for your reply. My application is to log SPL over long time and make statistics like average in real time (or near real time so what is call SPL Leq). It works like I want, but over a long period, display slow down. For limitation of array, I make reference to this post: viewtopic.php?f=2&t=1665&start=0

I have found a Ruby module/code which is near what I want, but i don't know how to implement a reset/clear function, and insert last data first in the array (and not lastest)
viewtopic.php?f=3&t=561&hilit=data+logging&start=10#p1789
latour
 
Posts: 6
Joined: Mon Sep 08, 2014 1:46 am

Re: Float to Array in Ruby

Postby tulamide » Fri Aug 21, 2015 11:19 pm

I still don't see an issue with the array. Arrays are fast as long as the memory doesn't need to be moved, which normally isn't the case. The limit for an array would be the free remaining memory. But with 60000 floats you're at 235 kB plus small overhead, so that's not an issue at all. You also probably don't want to record each float to disk like in the example you linked to, or do you?

The only factors that slow it down are the display used to show the data and the writing to disk, if you do so. But you didn't answer my question regarding the display, so I can't really help more, until I know or see, what type of display you're using.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Float to Array in Ruby

Postby MyCo » Fri Aug 21, 2015 11:36 pm

yep, probably a display issue... I used arrays with a lot more data (more than a million entries) and you wouldn't notice anything. However as soon as you connect it to a readout (display/text) that cycles through every single item, you can wait for minutes. There are workarounds though...
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Float to Array in Ruby

Postby Youlean » Fri Aug 21, 2015 11:51 pm

latour wrote:My application is to log SPL over long time and make statistics like average in real time (or near real time so what is call SPL Leq).

That could easily be done with blue. Here is blue for average calculating in real time. (you will need direc sound out of asio out inside shematics to use it)
BTW it can store as many data as you want, just change number "100000" inside shematics.
Attachments
Average.fsm
(1.23 KiB) Downloaded 896 times
Youlean
 
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Float to Array in Ruby

Postby latour » Sat Aug 22, 2015 6:22 pm

However as soon as you connect it to a readout (display/text) that cycles through every single item, you can wait for minutes.

The only factors that slow it down are the display used to show the data and the writing to disk, if you do so.

I don't use display for all data, no writing to disk, but I average the full array (in green) on each new data, so I think it is possible that is the problem.

I've made an average code in Ruby, it seems a bit better than green.

Code: Select all
array_sum = @array.reduce 0, :+
array_average = array_sum / @array.size
output array_average


How to preserve divison by zero when there's no data in array?

Maybe the solution for my problem will be to make a pre calculation of old data and stock it in a S&H. I will try it.
latour
 
Posts: 6
Joined: Mon Sep 08, 2014 1:46 am

Re: Float to Array in Ruby

Postby MyCo » Sat Aug 22, 2015 7:10 pm

For that purpose you don't need Ruby (as it is relatively slow on large amount of Data). You could use the "Array sum" primitive and divide by the number of entries. Pretty straight forward, but a hell of lot faster than Ruby.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany


Return to General

Who is online

Users browsing this forum: No registered users and 66 guests