Multiple Substitutions


    Oct 15 2019 | 9:40 pm
    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?

    • Oct 16 2019 | 1:08 am
      sprintf does stuff like that. and if all other things fail, there is always the iter-itoa-select path.
    • Oct 17 2019 | 2:48 pm
      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
    • Oct 17 2019 | 6:56 pm
      Maybe this is helpful? Just exploring a bit based on the information you provided.
    • Oct 17 2019 | 9:59 pm
      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.
    • Oct 17 2019 | 10:00 pm
      Ah, cool. Good idea. :-)
    • Oct 18 2019 | 5:50 am
      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#"