jpcima / ysfx

Hosting library for JSFX
Apache License 2.0
161 stars 26 forks source link

Slider syntax #20

Closed ghost closed 2 years ago

ghost commented 2 years ago

Instead of waiting for more typos in other peoples code, I tried to do it all wrong myself and share the results here hoping it is somewhat helpful.

All the following examples compile and show in reaper.

These are 10 identical sliders:

slider1:official=0<-150,12,1>official
slider2:0<-150,12,1>official no var.name
slider3:=0<-150,12,1>=value
slider4:<-150,12,1>no default
slider5:0<-150,12,1,,,>toomanycommas
slider6:0<-150,12,1,2,3,4>toomanyvalues
slider7:0time<-150kilo,12uhr,1euro>strings
slider8:0*2<-150-151,12=13,1+3>math?
slider9:+/-0a0<-150<<-149<,12...13,1 3><v<<al..u e>
slider10:a1?+!%&<-150%&=/?+!,12!%/&?+=,1=/?+!%&>?+!%&=/

What (i think) i see is

If fields are empty:

//(if either min or max >=10 then increment=0.1 (for following 3 examples))

slider11:<-6>   //-> 0<-6,0,0.01>
slider12:<,6>   //-> 0<0,6,0.01>
slider13:<6,>   //-> 0<6,0,0.01>

slider14:<3,,>   //-> 0<3,0,0>
slider15:<,3,>   //-> 0<0,3,0>
slider16:<3,,1>  //-> 0<3,0,1>
slider17:<,3,1>  //-> 0<0,3,1>

//all nonsense -> all zero:
slider18:a1<b2,c3,d4>  //-> 0<0,0,0> (without string here, its not accessible)

Similar for menu slider:

jpcima commented 2 years ago

This is some of the must disgusting syntax ever seen. Thankfully we have unit tests. It's actually simpler to rewrite this in a manual parser, I think.

jpcima commented 2 years ago

That work is merged, can you give it a check? all 10 of the expressions above pass the test.

Most of the deal here is that number parsing is made according to C strtod rules: it extracts the largest leading part of the text which looks like a number, ignoring the rest. The parser then skips any junk that occurs prior to token characters.

As a note: If there exists an even worse syntax, that would be file_read regarding text files. This thing extracts either numbers or math-like expressions, of which i've not bothered to do the latter. seems like it's the only thing in computing that likes left-to-right priority rather than PEMDAS

ghost commented 2 years ago

Great! I checked with the plugin and all above examples are good. That should take care of all typos reaper lets slip through that I could think of. (regarding sliders that is, lets see if there is more :) ).

One small difference still: In jsfx an increment of 0 is a jump between min and max (slider14/15), where in ysfx it's a continuous slider with all values between min and max.

Oh and the scrollbar in the plugin is gone in sliderview.

jpcima commented 2 years ago

Oh and the scrollbar in the plugin is gone in sliderview.

This is fixed.

ghost commented 2 years ago

just a heads up that this is currently in the reaper dev branch: Includes feature branch: JSFX internals overhaul/cleanup/modernization https://forum.cockos.com/forumdisplay.php?f=37 followed by this (unofficial) announcement: https://askjf.com/index.php?q=5961s

jpcima commented 2 years ago

@mynameismuhl this topic goes on under "Discussions" https://github.com/jpcima/ysfx/discussions/33