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
it is about time...
43 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
Re: it is about time...
since std:: isnt available and math:: doesnt have it, it seems that
is the only way to go.
is that best practice? it is really hard to read for me, i know it as max(0, 5)
plus i think an array creates at least a namespace in memory, if not more troublesome stuff.
- Code: Select all
output [@f1, 5].max
is the only way to go.
is that best practice? it is really hard to read for me, i know it as max(0, 5)
plus i think an array creates at least a namespace in memory, if not more troublesome stuff.
Last edited by 110 on Mon Jan 23, 2017 10:32 pm, edited 1 time in total.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
Re: it is about time...
just following along with your posts 110.
I noticed RUBY ERRORs in this last example. It seems the 'period' after a number is throwing an error.
I removed the 'dot', and the calculations show. [i've not verified the correctness of the calculation].
Anyway, just thought I'd mention, as I look to learn every chance I get.
thanks for your posts !
I noticed RUBY ERRORs in this last example. It seems the 'period' after a number is throwing an error.
I removed the 'dot', and the calculations show. [i've not verified the correctness of the calculation].
Anyway, just thought I'd mention, as I look to learn every chance I get.
thanks for your posts !
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: it is about time...
i know that the one or other is following and wonders how to help. it is probably not so obvious what i exspect.
so i just share my experience, better than nothing.
so i just share my experience, better than nothing.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
Re: it is about time...
which period, that 69. in the rightmost module?
yes, thats also coming from maxmsp-expr where this dot indicates that the number is a float and should also be used like that.
while it is valid to write expr $f1*69 in max and returns a float (because the variable $f1 is of type float), you will run into trouble when you try to do expr $f1/69 - because the division will now be performed in int, so if you send a 17 in this thing it will return 0. float.
unlike in pure data, we know int and float in max and in most situations using a float matters (expr is actually one of the few exceptions), and we may write 69. for 69.0 .
i guess if i take all these things into account for automatic conversion of my expressions, my max-to-ruby max-patch will be more complicated in the end than my most complicated expression is.
yes, thats also coming from maxmsp-expr where this dot indicates that the number is a float and should also be used like that.
while it is valid to write expr $f1*69 in max and returns a float (because the variable $f1 is of type float), you will run into trouble when you try to do expr $f1/69 - because the division will now be performed in int, so if you send a 17 in this thing it will return 0. float.
unlike in pure data, we know int and float in max and in most situations using a float matters (expr is actually one of the few exceptions), and we may write 69. for 69.0 .
i guess if i take all these things into account for automatic conversion of my expressions, my max-to-ruby max-patch will be more complicated in the end than my most complicated expression is.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
Re: it is about time...
110 wrote:since std:: isnt available and math:: doesnt have it, it seems that
- Code: Select all
output [@f1, 5].max
is the only way to go.
is that best practice? it is really hard to read for me, i know it as max(0, 5)
plus i think an array creates at least a namespace in memory, if not more troublesome stuff.
not really. When you call [a,b,c].max what happens is array is created, max method is called upon it and array gets discarded. If you had function like max(a,b,c) what would ruby do is create array [a,b,c] and pass that array to the max(*p) method. it is effectively the same thing happening. If you really want to use traditional max/min method you can easily create one:
- Code: Select all
def max(*p)
p.max
end
def min(*p)
p.min
end
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: it is about time...
interesting!
so i know two working methods now to choose from.
here is the next issue. for noise with chi distribution i need to trigger this
((Math.sqrt(-2.0*Math.log(1.0-(rand))))*(Math.cos((rand)*6.283185307))**2.0)
for n times and accumulate the result.
no idea how to do that in ruby - and no idea how to make 5 consecutive triggers from 1 outside the ruby object.
both would be a good exercise.
so i know two working methods now to choose from.
here is the next issue. for noise with chi distribution i need to trigger this
((Math.sqrt(-2.0*Math.log(1.0-(rand))))*(Math.cos((rand)*6.283185307))**2.0)
for n times and accumulate the result.
no idea how to do that in ruby - and no idea how to make 5 consecutive triggers from 1 outside the ruby object.
both would be a good exercise.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
Re: it is about time...
it seems i could do
where i need
to output 0 and 1.
but it looks a bit strange and converting that programatically will be more work then to type it by hand.
- Code: Select all
[(@f1<=>1.0), 0.0].max
where i need
- Code: Select all
(@f1<1.0)
to output 0 and 1.
but it looks a bit strange and converting that programatically will be more work then to type it by hand.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
Re: it is about time...
110 wrote:which period, that 69. in the rightmost module?
Yes ... for that example, I just added a '0' after the period ---> 69.0
It seems SYNTAX is particular about this.
Same thing [i believe] with examples like: 0.123456 It seems the 0 in front of the decimal point is required.
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: it is about time...
right, there were more errors like that, they just didnt show up as errors as inputs were missing and stuff.
so now here...
nice try, 110, but "stack level too deep". hmpf.
so now here...
- Code: Select all
output (Math.log(@f1))
def Math.log(*p)
log(*p)
end
output (log(@f1))
nice try, 110, but "stack level too deep". hmpf.
- 110
- Posts: 40
- Joined: Mon Jan 16, 2017 3:20 pm
43 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: Google [Bot] and 88 guests