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
Callbacks in Ruby?
47 posts
• Page 5 of 5 • 1, 2, 3, 4, 5
Re: Callbacks in Ruby?
Hey folks
I just tried Exo's latest solution and found that while it works, it only works with one instance of both the call and callback modules. Multiple instances create an error in the Ruby block for one reason or another.
I think I will try the global variable solution. What I came looking for is a sort of wireless "last switched" with X amount of wireless connections. So I needed to wire them all to the same connection, but I wanted to set the most recent value, not add them all together. Setting a global variable in Ruby should be exactly that. Lucky I found this thread!
Does the order the Ruby blocks are placed in the schematic matter (class declaration stuff)?
Oh, one more question: is it possible to name a variable in Ruby based on an input string?
Edit: I modified this ever so slightly for my own use. However, while it works without a hitch in this .fsm, I can't get this to work in my current project after a reload no matter how high up I place the class declaration block or what order I place things in. I need to send a trigger to the class block or switch it off and on and then everything works like a charm. And the After Load prim doesn't work. Any thoughts?
I just tried Exo's latest solution and found that while it works, it only works with one instance of both the call and callback modules. Multiple instances create an error in the Ruby block for one reason or another.
I think I will try the global variable solution. What I came looking for is a sort of wireless "last switched" with X amount of wireless connections. So I needed to wire them all to the same connection, but I wanted to set the most recent value, not add them all together. Setting a global variable in Ruby should be exactly that. Lucky I found this thread!
Does the order the Ruby blocks are placed in the schematic matter (class declaration stuff)?
Oh, one more question: is it possible to name a variable in Ruby based on an input string?
Edit: I modified this ever so slightly for my own use. However, while it works without a hitch in this .fsm, I can't get this to work in my current project after a reload no matter how high up I place the class declaration block or what order I place things in. I need to send a trigger to the class block or switch it off and on and then everything works like a charm. And the After Load prim doesn't work. Any thoughts?
- Attachments
-
- callback2 (tulamide, MyCo +PHI).fsm
- (602 Bytes) Downloaded 911 times
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Callbacks in Ruby?
Perfect Human Interface wrote:Does the order the Ruby blocks are placed in the schematic matter (class declaration stuff)?
Yes. In your case, not only the declarations, but also everything it depends on, needs to be interpreted first. Flowstone starts at the top layer and gets everything there in the order you created them. So for example, if you created the declaration instance last, but on the same layer are other ruby edits, you need to cut out everything but the declarations instance, then paste it back in.
Perfect Human Interface wrote:Oh, one more question: is it possible to name a variable in Ruby based on an input string?
It wouldn't be Ruby, if not!
- Code: Select all
instance_variable_set "@wow", "so easy"
watch "wow", @wow
a = instance_variable_get "@foo"
watch "foo existing?", "nope" if a == nil
a = instance_variable_get "@wow"
watch "wow existing?", "of course!" if a != nil
EDIT: Before you ask, yes, it also works for methods, modules and classes. For example:
- Code: Select all
def init
@black = Color.new 255, 30, 28, 26
end
def draw view
method("g1").call view
end
def g1 v
p = Pen.new @black, 0.25
b = Brush.new @black
v.drawClosedCurve b, [ [15, 1], [29, 25], [1, 25] ], 0.75
end
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Callbacks in Ruby?
tulamide wrote:In your case, not only the declarations, but also everything it depends on
What does that refer to exactly?
I have the Class block in one level and all of the "set variable" blocks two module levels down. I've also tried cutting and pasting all the other blocks to ensure the Class block was placed first. Still it doesn't work for me on load.
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Callbacks in Ruby?
Perfect Human Interface wrote:tulamide wrote:In your case, not only the declarations, but also everything it depends on
What does that refer to exactly?
I have the Class block in one level and all of the "set variable" blocks two module levels down. I've also tried cutting and pasting all the other blocks to ensure the Class block was placed first. Still it doesn't work for me on load.
Since I don't know how exactly your schematic looks like, I just wanted to point out that other Ruby stuff that you might use for the callbacks needs to be ready when used. For example, if you not just place a green float prim to set the number, but another Ruby edit instance calculates the number and then sends it to the input, that instance needs to be interpreted before the callback system is interpreted, to make it run after load.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Callbacks in Ruby?
I've found the problem. Silly me.
I had the other instance of FS open in FL with the same callback functions in it.
Seems to be working fine now. But that also suggests that you can't have any instances of plugins sharing these variables, at all. From reading the thread I had gotten the impression that the variables would simply be shared, but here it just stopped working. Also note that instances of Flowstone itself are the same plugin (regardless of the project opened), and Fruity format exports MAY share the same trait since they're wrapped versions of Flowstone (would need to be tested). I'm going to guess based on information in this thread that VST exports count as different plugins and therefore won't have issues with Ruby global variables unless they're the same plugin.
So, not to state anything conclusively, but at least here having another project open with the same global variable broke my global variable stuffs!
I had the other instance of FS open in FL with the same callback functions in it.
Seems to be working fine now. But that also suggests that you can't have any instances of plugins sharing these variables, at all. From reading the thread I had gotten the impression that the variables would simply be shared, but here it just stopped working. Also note that instances of Flowstone itself are the same plugin (regardless of the project opened), and Fruity format exports MAY share the same trait since they're wrapped versions of Flowstone (would need to be tested). I'm going to guess based on information in this thread that VST exports count as different plugins and therefore won't have issues with Ruby global variables unless they're the same plugin.
So, not to state anything conclusively, but at least here having another project open with the same global variable broke my global variable stuffs!
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Callbacks in Ruby?
My question:
IS IT POSSIBLE that two different VST's can exchange strings via ruby???
If I use multiple Instances of the same plugin, the "global wireless" works really greeeaaat but how can I now let my controlpanel-plugIn control multiple Effectengine-plugIn's ?? (...these are two different dll's)
Thanxz for helping
IS IT POSSIBLE that two different VST's can exchange strings via ruby???
If I use multiple Instances of the same plugin, the "global wireless" works really greeeaaat but how can I now let my controlpanel-plugIn control multiple Effectengine-plugIn's ?? (...these are two different dll's)
Thanxz for helping
- Clemens W
- Posts: 5
- Joined: Mon Aug 31, 2015 2:11 pm
Re: Callbacks in Ruby?
Clemens W wrote:IS IT POSSIBLE that two different VST's can exchange strings via ruby???
No. To let two different vsts communicate, you'd need system services. There are quite a few, known as "interprocess communication". Probably the most suited one on Windows are pipes: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365780%28v=vs.85%29.aspx
But I have no clue if they are directly accessible via Win32 API.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
47 posts
• Page 5 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 87 guests