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

5 code lines polynomial waweshapr (green)

Post any examples or modules that you want to share here

5 code lines polynomial waweshapr (green)

Postby unkargherth » Sat Nov 17, 2012 1:41 am

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 1388 times
Free your memory, .. with a free(). Like a pointer
Cast a pointer into an integer and it becomes the integer...
Cast a pointer into a struct and it becomes the struct...
A pointer can overflow... or can crash...
Be a pointer my friend
unkargherth
 
Posts: 29
Joined: Fri Apr 08, 2005 9:46 pm

Re: 5 code lines polynomial waweshapr (green)

Postby nix » Sat Nov 17, 2012 12:59 pm

ruby error.png
ruby error.png (20.45 KiB) Viewed 16197 times

I'm getting this error.
I don't know what I'm doing,
I haven't learned waveshaping
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: 5 code lines polynomial waweshapr (green)

Postby trogluddite » Sat Nov 17, 2012 1:54 pm

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.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: 5 code lines polynomial waweshapr (green)

Postby unkargherth » Sun Nov 18, 2012 7:14 pm

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)
Free your memory, .. with a free(). Like a pointer
Cast a pointer into an integer and it becomes the integer...
Cast a pointer into a struct and it becomes the struct...
A pointer can overflow... or can crash...
Be a pointer my friend
unkargherth
 
Posts: 29
Joined: Fri Apr 08, 2005 9:46 pm


Return to User Examples

Who is online

Users browsing this forum: No registered users and 99 guests

cron