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

6 bools in single preset parameter

For general discussion related FlowStone

6 bools in single preset parameter

Postby R&R » Sun Jul 30, 2023 11:36 am

In my struggle with huge bank (edit: txt files) loading times, schematic size, memory usage and other challenges...

This one gave me a laugh. There's probably some nifty bitwise operation or other method of storing more in a float :D But here is a fugly, yet straightforward way of using string to store 6 bools in a single preset parameter. Basically bitflipping with a parsed string.

I guess one should be able to store values between 1-8 in the six decimal positions as well... for selectors (other than just bool). Just change the switches to a knobs or sliders outputting an integer 1-8 instead.
Attachments
6_bools_in_single_preset_param_2.fsm
(10.76 KiB) Downloaded 552 times
Last edited by R&R on Sun Jul 30, 2023 6:45 pm, edited 2 times in total.
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Re: 6 bools in single preset parameter

Postby Tepeix » Sun Jul 30, 2023 5:51 pm

Interesting and inventive, but i'm really not sure that this will do an optimization.
Some variables is really really low memory, and when your plugin have to load, it will maybe do more tick and operation to retrieve the different value..
Consider a classic delay, or maybe buffer, you have so much more memory inside that you will need a lot of parameter to compete with this;
(even if i don't know if they load in the same way, but green is not real time sample rate)
Also, i don't know how in detail the preset works..

In fact, normally when the user doesn't change any parameter, the green or preset part will not slow anything,
except if graphic are refreshed, but did you encounter some slowdown when changing parameter or loading the plugin ?
Sometime i get some, but generally it's when i try to do a lot of calculation on large array..

Meanwhile even if i'm doubt this is an optimization, i tried to see if we could pack some boolean in a variable and come to this. Some 2^ number are added to a float, then divide to get range 0 to 1, then re multiply, then int to hex and hex to binary to finally extract the bit from text... Yep... They might be better way..
Attachments
Binary.fsm
(262.53 KiB) Downloaded 554 times
Tepeix
 
Posts: 355
Joined: Sat Oct 16, 2021 3:11 pm

Re: 6 bools in single preset parameter

Postby R&R » Sun Jul 30, 2023 6:25 pm

Tepeix wrote:Meanwhile even if i'm doubt this is an optimization, i tried to see if we could pack some boolean in a variable and come to this. Some 2^ number are added to a float, then divide to get range 0 to 1, then re multiply, then int to hex and hex to binary to finally extract the bit from text... Yep... They might be better way..


8-)
Hey! That looks interesting Tepeix, gonna take a closer look to see if I understand... I love those math approaches since i'm a dummy at coming up with math solutions :)

Tepeix wrote:Interesting and inventive, but i'm really not sure that this will do an optimization.
Some variables is really really low memory, and when your plugin have to load, it will maybe do more tick and operation to retrieve the different value..


Haven't tried my own solution yet on large scale :D

Yes and no... The thought is rather that reducing amount of parameters inside any "preset-bank.txt" should shorten loading of text-file time by atleast half. I'm at around 3000-3500 parameter per patch right now... That's about 240000 float values that has to be read from a flat file format :lol: :lol: :lol:
So the optimization isn't related to performance in that sense, when parameters are already in memory.

It might also reduce the size of the FS project by a tiny amount. For me it would maybe 100kb or more, since I can get rid of hundreds of param-prims and some surrounding green prims.

Whether my solution will make switching between presets any faster I'm less optimistic, since FS is very fast at what it does once everything is in memory...
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Re: 6 bools in single preset parameter

Postby tulamide » Sun Jul 30, 2023 11:38 pm

You both have interesting approaches, and of course an exponent to the power of 2 is the most intuitive. However, you both forget, that a 32-bit float is incapable of representing every possible value. By converting back and forth, small errors might occur. In other words, I would not advise to rely on this.

Of course, just setting bits of an integer and then saving the integer would be possible, and one could use the string preset for it. This has another advantage. Ruby does not just know one number system. You can work with decimal, binary, hex, oct and more.

But how do I display a binary number? Using to_str with the new base in round brackets. For example
3.to_str(2)
will display
11
It is now a binary string (base 2) and as a string it can be saved as such to the preset. When you load the preset, you have two possible ways to continue with the number. Either bitstring.to_i(2), which will convert it back to a decimal integer and result in 3, or by using the same approach as R&R and splitting the str. But careful! A binary string has its lowest bit on the far right and its highest on the far left (a behavior that can be changed, google little endian and big endian), but by default it is like that.

Code: Select all
a = 5.to_s(2) ## results in "101"
b = a.split(//).map { |c| c.to_i} ## results in [1, 0, 1]


You now have an array with the lowest bit at index 2 and the highest at index 0. split is a method that takes an argument (a regexp), but if you use it as shown in the example split(//) it simply creates an array with each char separated ["1", "0", "1"]. The method 'map' then converts each array entry into an integer that you could use to feed your switches or whatever else you need it for.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2688
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: 6 bools in single preset parameter

Postby Spogg » Mon Jul 31, 2023 7:35 am

R&R wrote:In my struggle with huge bank (edit: txt files) loading times ...


Is this in the FS schematic view? Is it much faster in the exported VST?

I ask this because I recently found out that green performance in the FS editor gets slower as the schematic grows in size, which makes knobs “sticky” and displays jumpy, and this also affects preset and bank save and load times. You can also get stream glitches sometimes if you move a knob.

If you do CTRL-HOME the Navigator and Toolbox go away and no longer take loads of time to re-draw. To get back to normal just do CTRL-HOME again.
User avatar
Spogg
 
Posts: 3327
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: 6 bools in single preset parameter

Postby R&R » Mon Jul 31, 2023 8:15 am

Thanks for the feedback Tulamide!

tulamide wrote:It is now a binary string (base 2) and as a string it can be saved as such to the preset.


Do you mean with a custom file reader/saver or? Since FS default preset system only deals with float 0 to 1.0... or have I missed something fundamental here? :?
Admit I haven't messed with these things until now when it's causing some trouble in regards to loading time of large text-file :)

tulamide wrote:But careful! A binary string has its lowest bit on the far right and its highest on the far left (a behavior that can be changed, google little endian and big endian), but by default it is like that.

You now have an array with the lowest bit at index 2 and the highest at index 0. split is a method that takes an argument (a regexp), but if you use it as shown in the example split(//) it simply creates an array with each char separated ["1", "0", "1"]. The method 'map' then converts each array entry into an integer that you could use to feed your switches or whatever else you need it for.


I really like the idea of working with regex. Also flattening array into integer is a nice method indeed.

I did experience the precision issue with float, that's why I ended up with the crudest solution possible as first draft :lol:
I'm uncertain in what way (probably a few) my crude solution posted here could fail, since it forces integer no matter of unreliable, dubious precision of float, either read by, or outputted by the param-prim.
That being said... if failure can be provoked without altering the solution it would be nice to see... to avoid it :)
Last edited by R&R on Mon Jul 31, 2023 8:36 am, edited 1 time in total.
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Re: 6 bools in single preset parameter

Postby R&R » Mon Jul 31, 2023 8:26 am

Spogg wrote:Is this in the FS schematic view? Is it much faster in the exported VST?

I ask this because I recently found out that green performance in the FS editor gets slower as the schematic grows in size, which makes knobs “sticky” and displays jumpy, and this also affects preset and bank save and load times. You can also get stream glitches sometimes if you move a knob.

If you do CTRL-HOME the Navigator and Toolbox go away and no longer take loads of time to re-draw. To get back to normal just do CTRL-HOME again.


In this particular case it's the insane loading time of preset-bank.txt files, both in editor and as plugin/standalone i'm trying to solve, mostly :D

I do remember you mentioning that... and try to have that in the back of my mind when encountering similar glitches :)

I still edit my plugin using the older FS version, but it was a while ago since I even tried demo:ing my plugin with sound using FS 3.06/3.08.
Feels like only FS4 can handle my plugin properly. I've pushed the schematic to far :lol:

It pushes up to 20% cpu on single note, and only works with large buffer size/high latency.
And for example simple thing (some selector switching) turning off the scope makes the sound die... etc etc etc.

In FS4 it works flawlessly however 8-)
Last edited by R&R on Mon Jul 31, 2023 11:19 am, edited 2 times in total.
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Re: 6 bools in single preset parameter

Postby R&R » Mon Jul 31, 2023 8:47 am

R&R wrote:And for example simple thing (some selector switching) turning off the scope makes the sound die... etc etc etc.


I know exacly what junction and selector that's causing this, and that's the useful thing about older FS. If it can be fixed in older FS I know it'll work 100% in FS4.
But it's not really any connection/selectors at this point it seems, but the spike when reloading schematic that tips FS3.08 over the edge and crashes. I see it with others schematics as well.

Old FS 32-bit exports have very slow performance compared to FS4 exports, even when 32-bit. Must be significant changes to the engine...
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Re: 6 bools in single preset parameter

Postby tulamide » Mon Jul 31, 2023 12:11 pm

R&R wrote:Do you mean with a custom file reader/saver or? Since FS default preset system only deals with float 0 to 1.0... or have I missed something fundamental here? :?
Admit I haven't messed with these things until now when it's causing some trouble in regards to loading time of large text-file :)

Yes, you miss something fundamental ;)
PresetString.PNG
PresetString.PNG (2.72 KiB) Viewed 17689 times


Regarding float precision, I think this article will help you understanding the issue, and why using 8 digits for fractions already becomes imprecise.
https://blog.demofox.org/2017/11/21/floating-point-precision/
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2688
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: 6 bools in single preset parameter

Postby R&R » Mon Jul 31, 2023 1:49 pm

OMG LOL :lol:

I've never needed it until now... but still, I must have flipped past it 3 million+ times by now :P :oops:

tulamide wrote:Yes, you miss something fundamental ;)


Correct! "miss" is the right word, not missed. Definately a lack of brain activity behind the keyboard in front of me :lol: :lol: :lol:

Well then my MacGyver ideas can happily be thrown in the trash this time...
If I can have strings, the sky is the limit... HEX or straight of using any number of letters as the base. Splendid!

tulamide wrote:Regarding float precision, I think this article will help you understanding the issue, and why using 8 digits for fractions already becomes imprecise.
https://blog.demofox.org/2017/11/21/flo ... precision/


Certainly a good read for me... These things never seem to stick for any period of time in my peanut brain :roll:
R&R
 
Posts: 448
Joined: Fri Jul 15, 2022 2:28 pm

Next

Return to General

Who is online

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