Re: FlowStone 3.0.2 Released
Posted: Thu Mar 07, 2013 11:47 pm
Hi nix,
There are a couple of things that don't look right in that code.
- You are calling 'init' from inside the 'event' method. So if @samples and @samplerate are, as I guess, labels for external inputs, they are getting reset to the 'init' defaults every time there is an event. If they are input labels, then the schematic will store their values when you save the schematic, so you probably don't need to initialise them.
- Where is @in_id coming from?
It looks as if you are trying to use it as an input filter (I use that variable name a lot in my own 'event' methods, so I guess you saw it there). To be able to test which input triggered, it needs to be the first parameter of the 'event' declaration, and must be a local variable (no '@')....
def event (in_id)
(NB - the dev's examples usually use 'i', but the name is not important so long as it is the first parameter - actually I'm not keen on their Ruby coding style at all, but that's another story!)
Since your 'event' method has no parameters defined, and 'init' sets @in_id to zero, the 'if' test is always true, so will fire for a change on any input.
-
There's no feedback within the code, so is this being done externally using links?
-
Not sure what you mean, there isn't a default 'checkInited' method, is this somewhere in the code you removed?
To test if an instance ('@') variable has been declared, use the '.nil?' test, e.g...
<do something> if @variable.nil?
Note that this only works for instance variables; local variables (without '@') will cause an error if they are used before they are declared.
Instance variables exist anywhere within the primitive, but local variables are only valid inside the "def ... end" of the method where they are created.
You could also use the special "or equals" method...
@variable ||= value
If @variable is not declared yet it gets the value - but if it already has a value, the old value gets kept.
I don't see anything that could lead to a namespace clash, so my guess it that when "is playing" is on (which it only can be inside a host), something is causing a nasty feedback loop - probably because the input testing is not filtering out events that it should be. But without seeing the full schematic, it's hard to be sure. Maybe make a new thread with some attachments so that we can get to the bottom of it.-
There are a couple of things that don't look right in that code.
- You are calling 'init' from inside the 'event' method. So if @samples and @samplerate are, as I guess, labels for external inputs, they are getting reset to the 'init' defaults every time there is an event. If they are input labels, then the schematic will store their values when you save the schematic, so you probably don't need to initialise them.
- Where is @in_id coming from?
It looks as if you are trying to use it as an input filter (I use that variable name a lot in my own 'event' methods, so I guess you saw it there). To be able to test which input triggered, it needs to be the first parameter of the 'event' declaration, and must be a local variable (no '@')....
def event (in_id)
(NB - the dev's examples usually use 'i', but the name is not important so long as it is the first parameter - actually I'm not keen on their Ruby coding style at all, but that's another story!)
Since your 'event' method has no parameters defined, and 'init' sets @in_id to zero, the 'if' test is always true, so will fire for a change on any input.
-
nix wrote:This my timer, the output gets fed back into the input.
There's no feedback within the code, so is this being done externally using links?
-
nix wrote:So I am looking at the way checkInited is set up by RDSP
Not sure what you mean, there isn't a default 'checkInited' method, is this somewhere in the code you removed?
To test if an instance ('@') variable has been declared, use the '.nil?' test, e.g...
<do something> if @variable.nil?
Note that this only works for instance variables; local variables (without '@') will cause an error if they are used before they are declared.
Instance variables exist anywhere within the primitive, but local variables are only valid inside the "def ... end" of the method where they are created.
You could also use the special "or equals" method...
@variable ||= value
If @variable is not declared yet it gets the value - but if it already has a value, the old value gets kept.
I don't see anything that could lead to a namespace clash, so my guess it that when "is playing" is on (which it only can be inside a host), something is causing a nasty feedback loop - probably because the input testing is not filtering out events that it should be. But without seeing the full schematic, it's hard to be sure. Maybe make a new thread with some attachments so that we can get to the bottom of it.-