Page 1 of 1

5 code lines polynomial waweshapr (green)

Posted: Sat Nov 17, 2012 1:41 am
by unkargherth
The simplest form of a polynomial waveshaper for green floats. Version 0.1 Alpha

TODO:
.- Convert to Mono
.- Allow more math primitives

simplepolywaveshape.fsm
(7.04 KiB) Downloaded 1471 times

Re: 5 code lines polynomial waweshapr (green)

Posted: Sat Nov 17, 2012 12:59 pm
by nix
ruby error.png
ruby error.png (20.45 KiB) Viewed 17320 times

I'm getting this error.
I don't know what I'm doing,
I haven't learned waveshaping

Re: 5 code lines polynomial waweshapr (green)

Posted: Sat Nov 17, 2012 1:54 pm
by trogluddite
Looks like t's telling you that you haven't give the variable @x a value yet. Undeclared variables always return nil.
What is probably happening is that when you retype code, the whole primitive is parsed again, and this sometimes clears the values in the input variables. Ruby primitives don't "request" values from upstream modules like green does, you have to push a value in from outside, so after an edit you sometimes need to refresh the input values by triggering them. This also means that input values don't default to zero like they do in green - if you haven't triggered an input yet, it will always show nil - this is catching me out all the time too.
Best thing to do is to put a test in the code, e.g.

Code: Select all

if @x
  #do some stuff with @x#
else
  raise "@x is not set yet in MyMethod"
end

The raise command send an error message to the console - using this inside your method definitions will make bug tracing 100% easier.

Re: 5 code lines polynomial waweshapr (green)

Posted: Sun Nov 18, 2012 7:14 pm
by unkargherth
OK. my mistake. Seems to be solved if the line reading

Code: Select all

output eval(@toEval)

is changed to

Code: Select all

output eval(@toEval) if (@toEval && @x)