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 4 of 5 • 1, 2, 3, 4, 5
Re: Callbacks in Ruby?
MyCo wrote:I'm a bit concerned though... When I remember correctly, classes are shared between the plugins as well
See Attachment
Yes this is concerning!
What will happen if there is a clash in class names?
If I declare class "Foo" and then someone else in their plugin has declared the same class, what happens?
Would one be completely overridden, ignored or modified?
If it would just be modified (adding new methods) then everything would seemingly be fine unless someone declares a method or class variable with same name. Which is very likely in the case of the class name being the same, because it will probably be doing a similar or same thing.
So it seems much more important now to declare classes in their own name space to avoid conflicts.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Callbacks in Ruby?
fs 3.03 changelog:
"The ruby dll no longer needs to be distributed with exported plugins because we now link it directly with our code. As a result of this each plugin now has its own Ruby interpreter, no more worrying about potential conflicts with other people's plugins."
shouldn't this be same for having more instances of the same plugin?
"The ruby dll no longer needs to be distributed with exported plugins because we now link it directly with our code. As a result of this each plugin now has its own Ruby interpreter, no more worrying about potential conflicts with other people's plugins."
shouldn't this be same for having more instances of the same plugin?
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: Callbacks in Ruby?
Just checked it. The same DLL loaded twice share the same interpreter. When you copy the DLL file and load the original and the copy, they don't share the interpreter.
That's just because DLLs are loaded by the host only once into memory, and the ruby interpreter get's initialized on DLL load. So any DLL has its own interpreter, but instances of the VST in the DLL share the same interpreter.
That's just because DLLs are loaded by the host only once into memory, and the ruby interpreter get's initialized on DLL load. So any DLL has its own interpreter, but instances of the VST in the DLL share the same interpreter.
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Callbacks in Ruby?
Ah I thought we was talking about ALL plugins not just instances of the same one.
This then is much less of an issue for me, as long as we know globals are shared amongst instances we can write code accordingly.
I have not looked at your example yet MyCo but I think the best solution then for a callback system is the original one I proposed. It is simple and doesn't rely on any global variables.
Global variables could be used for a callback system where we want to tell instances to update themselves with a change from another instance. I can think of some use in that.
This then is much less of an issue for me, as long as we know globals are shared amongst instances we can write code accordingly.
I have not looked at your example yet MyCo but I think the best solution then for a callback system is the original one I proposed. It is simple and doesn't rely on any global variables.
Global variables could be used for a callback system where we want to tell instances to update themselves with a change from another instance. I can think of some use in that.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Callbacks in Ruby?
Exo wrote:Ah I thought we was talking about ALL plugins not just instances of the same one.
Me too
"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 have come up with yet another solution
This one doesn't use global variables but relies on wireless links. This I think is the ideal solution, the callback method can only be called from the same level or below. If you wanted to call it from above to below then I actual think just using wireless links is more appropriate .
The benefit also of using a wireless link is "Follow wireless" feature in menu. Now it is easy to find where the callback is called!
I also decoupled the class declaration from the implementation of the callback. Now the data is passed seamlessly to the outputs. When calling "actionPerformed" we pass an Event object which contains the output name and the data, also we pass a reference to the object (ie RubyEdit, but could be any object). With this "source" object we can then call any methods that belong to it. I currently don't make use of "source" object but we can override the actionPerformed method when we create the class. We can then "callback" into the source object to get any extra data we might need.
This method is very generic, safe (no globals) and can seamlessly pass any type of data! Just set up your outputs with names and then send the Event with that name.
We can also easily create new callbacks without having to define brand new callback classes. The previous methods meant that you couldn't have more than one without duplicating code and creating basically the same class but with a slightly different name.
This one doesn't use global variables but relies on wireless links. This I think is the ideal solution, the callback method can only be called from the same level or below. If you wanted to call it from above to below then I actual think just using wireless links is more appropriate .
The benefit also of using a wireless link is "Follow wireless" feature in menu. Now it is easy to find where the callback is called!
I also decoupled the class declaration from the implementation of the callback. Now the data is passed seamlessly to the outputs. When calling "actionPerformed" we pass an Event object which contains the output name and the data, also we pass a reference to the object (ie RubyEdit, but could be any object). With this "source" object we can then call any methods that belong to it. I currently don't make use of "source" object but we can override the actionPerformed method when we create the class. We can then "callback" into the source object to get any extra data we might need.
This method is very generic, safe (no globals) and can seamlessly pass any type of data! Just set up your outputs with names and then send the Event with that name.
We can also easily create new callbacks without having to define brand new callback classes. The previous methods meant that you couldn't have more than one without duplicating code and creating basically the same class but with a slightly different name.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Callbacks in Ruby?
A solid, not harming solution. Most generic ones to date. Thanks for them!
"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 made an improvement, now new callbacks can be made and called with any number of inputs and data types without writing a single line of code!
All you have to do is make sure that you name the inputs and the outputs the same and everything will work.
I get the name of the input, pass it along with the Event and then use the input name to send to the output. So as long as these names match it works without modifying any code , no ugly if/elsif statements like in previous example.
All you have to do is make sure that you name the inputs and the outputs the same and everything will work.
I get the name of the input, pass it along with the Event and then use the input name to send to the output. So as long as these names match it works without modifying any code , no ugly if/elsif statements like in previous example.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Callbacks in Ruby?
That's awesome Exo...!
Ruby at its best: one line of code and it works
Keep on doing!
Walter
P.S.: I tried it also with a bitmap: works like a charm
Ruby at its best: one line of code and it works
Keep on doing!
Walter
P.S.: I tried it also with a bitmap: works like a charm
-
Walter Sommerfeld - Posts: 249
- Joined: Wed Jul 14, 2010 6:00 pm
- Location: HH - Made in Germany
47 posts
• Page 4 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 67 guests