Re: best way to obtain global presets?
Posted: Tue Feb 04, 2020 10:32 pm
I just had a look to see if I had any old parser examples in my old SM stuff that might help. With not much joy I'm afraid; I only found one! But here it is, in case it's any use to you - it's a just a simple parser for turning note names (e.g. "C#3") into their MIDI indexes...
The main things to note, I think are...
- The parser 'Action' primitive is equivalent to a regular expression 'capture'. You can chain as many other parser prim's as you want to the bottom output, and if they ALL match, the String output is the sum total of everything that they find. The top connector passes along the rest of the string after the match.
- The 'Sequence' primitive is equivalent to a regex 'sub-expression'. Everything at the top output must match, and if it does, the rest of the string is passed to the bottom output.
- Things like matching repeats (+, *) and optional matches (?) go before the pattern that they match, not after as they would in a regex. Unless the multiple/optional match is the last thing in the string, you'll have to use an 'Action' or 'Sequence' to effectively make it a 'sub-expression'.
- The 'green' outputs for matched parts of Strings send a trigger every time that they are matched - so, for example, it is possible to collect the matches for a repeating part (+ or *) in an array by using the 'before match' trigger to set the index to zero and then incrementing by one for each match trigger.
- If you collect parser primitives into a module, make sure to have an output to pass through the remainder of the string. You can make a little collection of sub-expression matchers which will chain together that way.
Aside from that, I'm pretty rusty myself, so it will interesting to see what you discover!
(PS. To anyone who can't find the parser primitives in their toolbox: you need to turn on the "R&D components" option in the 'Advanced' options before they'll show up - they are included in a standard installation.)
The main things to note, I think are...
- The parser 'Action' primitive is equivalent to a regular expression 'capture'. You can chain as many other parser prim's as you want to the bottom output, and if they ALL match, the String output is the sum total of everything that they find. The top connector passes along the rest of the string after the match.
- The 'Sequence' primitive is equivalent to a regex 'sub-expression'. Everything at the top output must match, and if it does, the rest of the string is passed to the bottom output.
- Things like matching repeats (+, *) and optional matches (?) go before the pattern that they match, not after as they would in a regex. Unless the multiple/optional match is the last thing in the string, you'll have to use an 'Action' or 'Sequence' to effectively make it a 'sub-expression'.
- The 'green' outputs for matched parts of Strings send a trigger every time that they are matched - so, for example, it is possible to collect the matches for a repeating part (+ or *) in an array by using the 'before match' trigger to set the index to zero and then incrementing by one for each match trigger.
- If you collect parser primitives into a module, make sure to have an output to pass through the remainder of the string. You can make a little collection of sub-expression matchers which will chain together that way.
Aside from that, I'm pretty rusty myself, so it will interesting to see what you discover!
(PS. To anyone who can't find the parser primitives in their toolbox: you need to turn on the "R&D components" option in the 'Advanced' options before they'll show up - they are included in a standard installation.)