Multiple Substitutions
I'm trying to integrate different note spellings for the nslider object : for every black key, I want to be able to choose whether I want it to appear as flat or sharp. By default, all black keys appear as sharps, so I need to add a "-" sign in front of selected pitches in order to make them appear as flats.
How can I select specific ints from a list and add a "-" sign to them? I got close using regexp, but as shown in my exemple matching the int 1 will add a "-" sign in front of every "1" number (ie : 121 ---> -12-1).
Is there a zl function for this?
sprintf does stuff like that. and if all other things fail, there is always the iter-itoa-select path.
I've never used sprintf and trying to learn how to use it, but I'm afraid I'll need a little help here...
In this patch, the number of integers in the list is variable, as it depends on the number of notes being simultaneously pressed on the keyboard. Also, the integers vary from 1 to 3 digit (0-127). How do I manage to output the whole list as-is, while adding a "-" sign before specific numbers?
Something that would be the equivalent to this regexp if the "-" sign would be placed only in front of each of these multiple integers, rather than in front of each decimal number :
regexp (13|25|37|49|61|73|85|97|109|121) @substitute -%1
Maybe this is helpful? Just exploring a bit based on the information you provided.
Ha! I didn't think this would be so complicated. Thanks for your help! I actually ended up converting the numbers with sprintf before creating the lists, which is so much simpler...don't know why I didn't think about it sooner.
Ah, cool. Good idea. :-)
i dont understand the situation, but if it is the same for every octave, you could first split the note numbers into key and octave numbers
"61" -> "2, 6"
and then decide whether "2" is "Db" or "C#"