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

Adding Preset to Edit Box

For general discussion related FlowStone

Adding Preset to Edit Box

Postby Perfect Human Interface » Fri Sep 05, 2014 12:45 am

I'm using edit boxes to set MIDI port numbers in my schematic. I need the plugin to remember the settings on load so I'm adding preset parameters to the edit boxes.

I've uploaded what I've done below. The problem is that when I set it to a value (say 8), on reload the value loaded is 7. This suggests a rounding error (the schematic multiplies the value by 1/127 to achieve a 0-1 scale and then multiplies by 127 after the preset prim). However, I don't get any rounding errors with this math while testing within the schematic. Not sure what else to do at this point.

Any help is appreciated.
Attachments
MIDI Port Edit Box.fsm
(1.31 KiB) Downloaded 908 times
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Adding Preset to Edit Box

Postby KG_is_back » Fri Sep 05, 2014 2:18 am

Works perfectly fine here, except for one minor thing - you are missing a "last switch" just before the "edit control" primitive's string input. If you input value via the module input, you get the number written twice.
I do not experience the rounding problems either. In preset manager, when the preset is saved it is saved as decimal number (with exactly 6 decimal places, no matter the size - pretty much the same thing you get when connecting text prim to float array output). On the other hand, float is converted to int by removing everything after decimal dot, so maybe using rounding to int will help.

Following ruby code should do the trick
Code: Select all
output 0,'%.0f' % @ins[0]

the input should be float and output can be anything (string, float or int - all give the same result, in your case I recommend string, cos that is being processed afterwards)
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Adding Preset to Edit Box

Postby Perfect Human Interface » Fri Sep 05, 2014 6:11 pm

I dropped your rounding code in and that seems to keep the values from changing. But when I export the plugin it won't save the values in a project. It will save the values in a preset, but reloading the project the plugin is loaded in loads them as default. That's actually the opposite of what I want, since I don't want/need the values to save in a preset but it's important they are remembered in a project save.

Uploaded current module. Same as before, just with the last switch and rounding code KG mentioned.

Edit: note that I'm talking about an exported plugin and not just loading the schematic inside Flowstone.
Attachments
MIDI Port Edit Box 2.fsm
(1.39 KiB) Downloaded 914 times
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Adding Preset to Edit Box

Postby tulamide » Sun Sep 07, 2014 8:50 am

The ruby component supports saving and loading data on schematic save/load via the functions loadState and saveState. Try this (not tested):

Code: Select all
@value = '%.0f' % @ins[0]
output 0, @value

def loadState v
   @value = v
end

def saveState
   @value
end
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Adding Preset to Edit Box

Postby Perfect Human Interface » Sun Sep 07, 2014 5:43 pm

tulamide wrote:The ruby component supports saving and loading data on schematic save/load via the functions loadState and saveState. Try this (not tested):

Code: Select all
@value = '%.0f' % @ins[0]
output 0, @value

def loadState v
   @value = v
end

def saveState
   @value
end


Thanks for the suggestion. I don't know Ruby so I can only guess at how this works. Where is the data saved?
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Adding Preset to Edit Box

Postby tulamide » Sun Sep 07, 2014 7:01 pm

I just know what I read in the user guide (You'll find it under the Ruby chapter, section 'Persistence'). It is a convenience function that seems to use the same 'store in schematic' function than all other modules/prims. That's why I thought it should restore its state when loading as a plugin.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Adding Preset to Edit Box

Postby Perfect Human Interface » Sun Sep 07, 2014 8:59 pm

That's interesting. Maybe that will work. I still don't understand why the preset param isn't working as it is though.
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Adding Preset to Edit Box

Postby billv » Sun Sep 07, 2014 11:37 pm

Perfect Human Interface wrote: I still don't understand why the preset param isn't working as it is though

My fist question was "what method is he using to re-load project"...
So I used my preset manager, where it autoloads whatever you save.
Didn't get correct result.., so went back a changed the Edit box circuit,
and set everything to int. Back in VST mode, works fine. re-loads exactly what is saved.
But this is using my PM, you'll have to try it using your own save/reload set-up.
MIDI Port Edit Box 2_fix.fsm
(12.7 KiB) Downloaded 909 times

Solution 2: :idea:
Instead of a Edit box, you can use a number knob.
This is probably much better idea, as user dosn't have to type in value.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Adding Preset to Edit Box

Postby Perfect Human Interface » Mon Sep 08, 2014 2:16 am

billv wrote:My fist question was "what method is he using to re-load project"...


I'm just using the stock preset manager. I notice that yours apparently takes any value. The stock manager needs a 0-1 value so I can't make everything into ints unfortunately.

So I tried removing the string input since it wasn't being used anyways. That didn't help. But I did notice while testing that when the plugin loaded into the project, it had the value it should have saved in the text field for a brief moment before the default value popped in there. So the thing is overwriting itself with the value saved with the plugin export. Preset manager y u do dis
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Adding Preset to Edit Box

Postby billv » Mon Sep 08, 2014 5:49 am

Perfect Human Interface wrote:The stock manager needs a 0-1 value so I can't make everything into ints unfortunately.

hey man, what made you think that..??...
If change your way of thinking on this and a whole new world will open up... ;)
The stock PM handles int just fine.
Perfect Human Interface wrote:So the thing is overwriting itself with the value saved with the plugin export.

My question still remains...
"What method are you using to re-load data on plug-in start-up"
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Next

Return to General

Who is online

Users browsing this forum: Google [Bot] and 73 guests