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

How can I make persistent ruby data within plugin?

For general discussion related FlowStone

How can I make persistent ruby data within plugin?

Postby Nowhk » Tue Nov 10, 2015 11:11 am

Hi,

I create an array and I randomize its value using a ruby function:

Code: Select all
def init
   @lfo_size = 100
   @lfo_shape_1 = Array.new @lfo_size
end

def event i, v
   if (i == "start")
        # somethings
   elsif (i == "random")
        randomLFOs
   end
end

def randomLFOs
   for i in 0..@lfo_size
      @lfo_shape_1[i]=rand(100)
   end
end

Once I create it, I'd like that every time I edit ruby script (recompile) or I close/reopen the project/plugin, the array stay persistent. So I work on the same values every time.

Once I re-random it, it recreate the array and store the new one. How this is possible in ruby? In Kontakt scripting for example I use make_persistent(myArray).

Is there somethings similar in FlowStone?
Thanks!
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How can I make persistent ruby data within plugin?

Postby KG_is_back » Wed Nov 11, 2015 2:16 am

You can use saveState and loadState methods to store values. it is described in the manual. However, I'm not sure if it will do what you are looking for
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: How can I make persistent ruby data within plugin?

Postby Nowhk » Wed Nov 11, 2015 12:49 pm

KG_is_back wrote:You can use saveState and loadState methods to store values. it is described in the manual. However, I'm not sure if it will do what you are looking for

Uhm yeah, it seems to works pretty nice:

Code: Select all
def loadState v
   @lfo_shape_1, @lfo_shape_2 = v
end

def saveState
   [@lfo_shape_1, @lfo_shape_2]
end

Why it shouldn't works? Thank you!
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm


Return to General

Who is online

Users browsing this forum: No registered users and 62 guests