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

it is about time...

For general discussion related FlowStone

Re: it is about time...

Postby 110 » Wed Jan 25, 2017 12:53 am

i dont get the manual about the scheduler.

the scheduler of the main thread runs only at 10 ms, but when you turn audio on, it runs at samplingrate?

both is hard to believe. i expected something like 0.5 or 1.0 milliseconds (think music sequencing)
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby KG_is_back » Wed Jan 25, 2017 6:02 am

110 wrote:so i´ve ben readin up on comparisons for an hour but i dont get it.

is there no simple method to compare two values and have it return a value?

i am writing small expressions using conditoinal statements like 300 * (a>0) + 500 * (a<=0) all the time, it is far more straight forward than splitting it up into 4 processes and use some kind of if type of statement... but 300 really wants to be multiplicated with 0 and 1 and doesnt really want to connect with "true".


There are several ways to handle this. You can for example modify the TrueClass and FalseClass to be convertible to int.

Code: Select all
class FalseClass; def to_i; 0 end end
class TrueClass; def to_i; 1 end end


with this you simply add .to_i every time you want the boolean to behave like a 0/1. for example in your formula:
300 * (a>0).to_i + 500 * (a<=0).to_i

Or even better, you can add coerce method into them. coerce method is used in ruby to convert numbers into common type (i.e when you multiply integer with float, it converts the int to float).

Code: Select all
#coerce method receives the second number "num and returns array of [num,self] both converted to common type
class FalseClass; def coerce(num); [num,0] end end
class TrueClass; def coerce(num); [num,1] end end


However, this makes it depends on the order of operands.
Code: Select all
9*(1>0) #returns 9. because multiply method is called upon 9 and within that method coerce is called, which does the conversion.
(1>0)*9 #raises error, because "*" method is not defined for TrueClass.


In both cases make sure the modification to the classes are made earier than they are used when schematic loads. For more info on how to do this and why, read page 231 in the manual (chapter "Declaration Order").
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: it is about time...

Postby 110 » Wed Jan 25, 2017 7:32 pm

okay, in my case i usually wrote the condition behind the statement, so that would work out.

but it is getting probematic if there is more than one condition, or if the rest of the calculation also aready contains comparison operators, right?

what do you think about my hack 5 * (1>0)?1:0
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 44 guests