float to hex converter

Post any examples or modules that you want to share here
Post Reply
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

float to hex converter

Post by KG_is_back »

Lately I needed to store a bunch of coefficients with preset manager and I've found out that the floats get rounded to 6 decimal places. That is OK when saving knob positions and bar graphs, but it is very poor when saving coefficients for a filter. This little tool can lossless convert float array to array of hex (string array) and vice versa, which let's you save your parameters with full precision.

I believe this can be dome much faster and easier in ruby...can someone do that too please?
Attachments
hex_float.fsm
(1.52 KiB) Downloaded 1318 times
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: float to hex converter

Post by Nubeat7 »

here`s a ruby version
Attachments
hex_float_ruby.fsm
(4.54 KiB) Downloaded 1396 times
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: float to hex converter

Post by KG_is_back »

Thanks Nubeat, this is great! This should be a default way to save floating point numbers in preset manager. Or there should be a boolean input on the preset parameter primitive to switch between classic (decimal) and precise (hex) parameter saving mode. Actually it also takes less space to save the number as 8 symbols rather than 7+ numbers and a decimal dot.
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: float to hex converter

Post by Nubeat7 »

you`re welcome KG, yes you are right, also when the file gets more cryptic but it isn`t here for change things anyway, it just gets bit morecomplicated when you need to compare or look the preset file for testreasons... but everything which make them smaller is good!

how did you modify the presetmanager to use hex?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: float to hex converter

Post by KG_is_back »

very simple - convert string array to string delimiting with random char (usually I use ? or * as they are rarely used) and save them using "string preset" primitive. extraction works other way around - convert string to string array by separating it at ? or * whichever is the case. ....actually for the float arrays saved as hex, you can simply convert them to string with no delimiter and convert them back by spliting them to 8 long strings.

It is written there that the string must be 255-long at max, but I never noticed any problem even with much longer strings.
Attachments
string preset.fsm
(355 Bytes) Downloaded 1307 times
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: float to hex converter

Post by Nubeat7 »

ah okay, so you collect parameters and save it under one presetname (why does longer strings then 255 works too?), but what about automation and parameter names then? would this work too, or is it only good for non automated parameters?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: float to hex converter

Post by KG_is_back »

This might work...

However, you probably don't benefit from lossless precision on automatable parameters
Attachments
string preset 2.fsm
(780 Bytes) Downloaded 1311 times
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: float to hex converter

Post by Nubeat7 »

oh, i didn`t know that the parameters will be recognised in the DAW when preset is off and automate is on - thats fine thanks!
Post Reply