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
23 posts
• Page 1 of 3 • 1, 2, 3
Adding Preset to Edit Box
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.
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 907 times
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Adding Preset to Edit Box
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
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)
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
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.
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 912 times
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Adding Preset to Edit Box
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
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
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
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
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.
Solution 2:
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.
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Adding Preset to Edit Box
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
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"
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
23 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 72 guests