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

XY pad - trigger limiting in RUBY

DSP related issues, mathematics, processing and techniques

XY pad - trigger limiting in RUBY

Postby Rocko » Wed Nov 23, 2016 5:07 pm

Hi all,

I'm building an XY pad for a parametric EQ. Currently it works OK, but CPU jumps on mouse dragging.
A single point XY pad example is attached.

(Only) when 'catching' the point and grabbing it around, the CPU jumps to ~30%.
I wonder if I can limit the CPU jump. The issue is that the 'XY pad' and 'mouse control' prims are in RUBY, so I can't just add a "redraw limiter'.

Is there a smart way I can limit the Ruby based 'mouse control module' to restrict the data sent (let's say ~20 commands per second) - to cut down CPU? Maybe using 't' (event i,v,t) ?

Any other CPU save or other remarks and comments, BTW?

Appreciated,
Rocko
Attachments
EQ_GUI.fsm
(4.88 KiB) Downloaded 1603 times
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: XY pad - trigger limiting in RUBY

Postby KG_is_back » Wed Nov 23, 2016 6:11 pm

yes, you can do something like this:

Code: Select all
def method
if (time-(@t||0))<0.05) #time difference between current and last call is less than 0.05
return #prematurely return from function
end

@t=time
####your code####
end

KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: XY pad - trigger limiting in RUBY

Postby Rocko » Thu Nov 24, 2016 3:32 pm

Hi,

Thanks for the answer... But I'm having some issues with this solution.
When moving the mouse at fast speeds, the system does filter the data out (less triggers counted), but I've noticed that the last position (in which mouse movement has stopped) - is not correct since the filter uses 'return' (data is simply thrown away).

The attached schematic is a good example. The 'display window' can be used as an XY pad, for dragging the mouse in all directions.
'mouse' module will output X and Y coordinates.

See image:http://imgur.com/uqiBO92

There are two 'trigger counters' before and after the 'trigger filter'. these show that the 'trigger filter' really works and how effective is it.
However, even if 'trigger filter' is set to 1/1000 - the last value might not always be correct.

Can I build (in someway) a system similar to 'De-Zipper' which (I believe) transfers all the data but slowly?

I'm out of my knowledge here...
Attachments
Trigger_Filter_Example.fsm
(11.43 KiB) Downloaded 1580 times
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: XY pad - trigger limiting in RUBY

Postby nix » Tue Dec 06, 2016 8:05 pm

I'm not very good in Ruby,
so I don't know how to implement it,
but maybe what you need is a last final trigger on 'mouse button up'?
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: XY pad - trigger limiting in RUBY

Postby Nubeat7 » Tue Dec 06, 2016 11:38 pm

i throws an error, its because @f is nil...

i did a xypad a while ago, here is it, i also included an trigger limiter ...
the ruby code can be optimized if you like, but normally it shouldn't be any problem...
Attachments
xy pad 02.fsm
(8.44 KiB) Downloaded 1572 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: XY pad - trigger limiting in RUBY

Postby Rocko » Thu Dec 08, 2016 1:31 pm

Hi,

Thanks for sharing appreciated.

On my machine, my original 'EQ_pad" takes upto 40% CPU on crazy dragging of mouse, while your "XY PAD 2" takes around 7. Impressive.

I'm no learning the difference between the two codes.

Let me ask you please what does this mean:

Code: Select all
@valx ||= 0.0
  @valy ||= 0.0


I'm not acquinted with that sign.

I also wonder why your code has a "mouseMoveCaptured x,y" command within the "mouseLDown" part?

Code: Select all
def mouseLDown x,y            
  captureMouse
  [b]mouseMoveCaptured x,y[/b]
  output 1,true
  redraw 0
end


It is followed by a mouseMoveCaptured x,y part anyway ?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: XY pad - trigger limiting in RUBY

Postby tulamide » Thu Dec 08, 2016 10:29 pm

|| means logical or, and is used as a trick here. The line is shortened, in full length it would read

Code: Select all
@valx = @valx || 0.0

And the trick is that the value only gets initialized to 0.0 if it doesn't exist yet. Any not yet initialized value is NIL and logical or of NIL and 0.0 will result in the non-NIL value. Any other number logical or'ed with 0.0 will result in the number.

Try this in a RubyEdit:
Code: Select all
b = nil
a = b
a.class #will tell you that a === NIL


And now this:
Code: Select all
b = nil
a = b || 0.0
a.class #will tell you that a === Float (which is the class of number 0.0)


And lastly this:
Code: Select all
b = 2
a = b || 0.0
a.class #will tell you that a === Fixnum (which is the class of the integer 2, as opposed to the Float 2.0)


The line you wanted to set in bold is a call to a method. The method definition follows later in the code (def mouseMoveCaptured x,y)
Calling this method from the mouseLDown method doesn't make sense anymore, but was needed pre 3.0.6.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: XY pad - trigger limiting in RUBY

Postby Rocko » Fri Dec 16, 2016 11:56 pm

Hi...

So I'm learning this.
I noticed that the pointer jumps to the X,Y point which is pressed, even if it is far from the original pointers location.

I'm trying to limit the mouse to 'capture' the pointer only if it is at the area of the pointer (pointer gets "sticky" only if mouse is on it). However I failed to do it. I get initialization errors all the time.

;-(
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: XY pad - trigger limiting in RUBY

Postby Lex248 » Mon Dec 19, 2016 1:42 pm

Without Ruby, from Parametric EQ in FlowStone.
Attachments
XY controls.fsm
(4.42 KiB) Downloaded 1485 times
Sorry, I bad speak english.
---
My plug-ins http://nalexsoft.blogspot.com/
Lex248
 
Posts: 33
Joined: Mon Aug 29, 2016 7:44 pm
Location: Russia

Re: XY pad - trigger limiting in RUBY

Postby 110 » Tue Jan 17, 2017 12:28 am

Rocko wrote:When moving the mouse at fast speeds, the system does filter the data out (less triggers counted), but I've noticed that the last position (in which mouse movement has stopped) - is not correct since the filter uses 'return' (data is simply thrown away).


this isnt a filter, it is how a mouse work.

and it is a regular problem with the mouse -> parameter game.

i dont know how to do that in flowstone (yet, as i am using it for only 30 minutes) but you can solve that like this:

- get the mouse (down) coordinate data from outside the gui element, too

- then limit the range of the data using min(max(0, input), 120)
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm


Return to DSP

Who is online

Users browsing this forum: No registered users and 21 guests