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

Callbacks in Ruby?

For general discussion related FlowStone

Re: Callbacks in Ruby?

Postby Exo » Sat Jan 31, 2015 7:28 am

MyCo wrote:I'm a bit concerned though... When I remember correctly, classes are shared between the plugins as well :twisted:

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.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: Callbacks in Ruby?

Postby Nubeat7 » Sat Jan 31, 2015 10:05 am

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?
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Callbacks in Ruby?

Postby MyCo » Sat Jan 31, 2015 10:22 am

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.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Callbacks in Ruby?

Postby Nubeat7 » Sat Jan 31, 2015 11:18 am

thx for clearing this myco
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Callbacks in Ruby?

Postby Exo » Sat Jan 31, 2015 11:25 am

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.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: Callbacks in Ruby?

Postby tulamide » Sat Jan 31, 2015 1:57 pm

Exo wrote:Ah I thought we was talking about ALL plugins not just instances of the same one.

Me too :D
"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?

Postby Exo » Sat Jan 31, 2015 6:46 pm

I have come up with yet another solution :)

New Callback.fsm
(1.6 KiB) Downloaded 867 times


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.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: Callbacks in Ruby?

Postby tulamide » Mon Feb 02, 2015 10:57 pm

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?

Postby Exo » Mon Feb 02, 2015 11:28 pm

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! 8-)

New Callback 2.fsm
(1.59 KiB) Downloaded 882 times


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. :)
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: Callbacks in Ruby?

Postby Walter Sommerfeld » Tue Feb 03, 2015 2:10 pm

That's awesome Exo...!

Ruby at its best: one line of code and it works :D

Keep on doing!
Walter

P.S.: I tried it also with a bitmap: works like a charm
User avatar
Walter Sommerfeld
 
Posts: 249
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 61 guests