sly.txt and ptfilter.txt contain the entire distribution. (c)2002 David Raleigh Arnold This software is completely free for all under the rules of GNU. The sly program itself contains only 12 lines of working bash code. ptfilter.sed is a filter for .ly files containing only notes (probably) and containing a measure (or more) on each line. A very minimal ptfilter sed is included in sly.txt. This version is something more than minimal. :-) After you have used sly for a while, try some of the routines below in ptfilter.sed. Some will be much more useful to you than others, and anything you don't like can be easily changed or onitted. The order of the routines in ptfilter.sed is critical. A design philosophy is really important for a tool which does nothing but use another program. It is simply that is should be possible to type everything completely in the same way that you would type it in an .ly file. sly, with ptfilter.sed affords an opportunity to try things out and see if you like them. :-) Many programs use 12345678 for semibreve-128th. Instead, I have 12487569. The mnemonic is to add the 1st and last digits to get one digit. If you would rather type 16 32 64 128 you can still do so. Be sure to put %stet in the 1st line of your lyrics, tab, or chord parts to pass them through without filtering. {} is changed to { }. You can use that to include spaces in something and still treat it as a single word. { } is a way to do extra spaces in LaTeX, insofar as you are supposed to do them at all. -------------- begin ptfilter.sed **current directory** # ptfilter.sed 020815 # replace tabs with spaces. s/ / contains a tab, really. # if you lose it, put it back. s/ / /g # remove leading spaces s/^ *//g # remove trailing spaces s/ *$//g # remove double spaces s/ */ /g # this comments, adds \measureRest. Define \measureRest in .ly # measureRest = s1. or whatever. Temporarily silences lines of # a part between %tacet and %attacca inclusively, # but keeps things aligned with no counting # of measures by you. %tacet or %attacca can be anywhere # in the line, and the whole line will be commented out. /%tacet/{ s/%tacet/\\measureRest % / :killing n s/%attacca// t s/^/\\measureRest % / b killing } # this routine stops filtration at %stet and resumes at end of file, # which is the end of the part not the score, or at %endstet. # This prevents ptfilter.sed from messing with lyrics. %stet will # not appear in the .ly file, and it may be anywhere in the line. /%stet/{ :topstet s/%stet// n s/%endstet// t outstet b topstet } :outstet # syntaxes: %xn, %an # multiply instances of next word. # up to 9. Min 2. Adding is too confusing. # works by fallthrough # example: %a9 nation %x9 termi # put these in ptfilter.sed before asterisk substitution. s/%x9 *\([^ ]*\)/%x8 \1 \1/g s/%x8 *\([^ ]*\)/%x7 \1 \1/g s/%x7 *\([^ ]*\)/%x6 \1 \1/g s/%x6 *\([^ ]*\)/%x5 \1 \1/g s/%x5 *\([^ ]*\)/%x4 \1 \1/g s/%x4 *\([^ ]*\)/%x3 \1 \1/g s/%x3 *\([^ ]*\)/%x2 \1 \1/g s/%x2 *\([^ ]*\)/\1 \1/g # append next word to max 9 following words. # syntax: %an appendage word1 word2... s/%a9 *\([^ ]*\) *\([^ ]*\)/\2\1 %a8 \1 /g s/%a8 *\([^ ]*\) *\([^ ]*\)/\2\1 %a7 \1 /g s/%a7 *\([^ ]*\) *\([^ ]*\)/\2\1 %a6 \1 /g s/%a6 *\([^ ]*\) *\([^ ]*\)/\2\1 %a5 \1 /g s/%a5 *\([^ ]*\) *\([^ ]*\)/\2\1 %a4 \1 /g s/%a4 *\([^ ]*\) *\([^ ]*\)/\2\1 %a3 \1 /g s/%a3 *\([^ ]*\) *\([^ ]*\)/\2\1 %a2 \1 /g s/%a2 *\([^ ]*\) *\([^ ]*\)/\2\1 %a1 \1 /g s/%a1 *\([^ ]*\) *\([^ ]*\)/\2\1/g # repeatchord.sed # precedes substitute.sed # repeat previous chord with <<>> # tested 20030825 :again /<<>>/{ # sub first chord ... <<>> # put all that 1st wd after s/\(<<[^>]*>>\)[^<]*<<>>/&\1/ s/<<>>// t again } # substitute.sed # this plugin routine replaces gub gub re<> <> with regub gub # tested 20030825 :again /<>/{ # sub 1stWord (saved) not<> ...<> # put (saved) at end of that s/\([^ ]*\)[^<][^>]*<>/&\1/ # del first word s/[^ ]*// # del leading spaces if any s/^ *// # del first <> s/<>// t again } # this is a working example of placing commands before and after next word. # keep this as a template, it is a bit tricky, and not well tested. # Do an override with a value (mycommand1) # and then a revert (mycommand2) after the next word. Define # the revert in the .ly file. :-) # todo: make it work before ``<<'' and putting after ``>>'' as well. :domore /%command/{ s/%command *\([^ ]*\)/mycommand1 \1 mycommand2 / t domore } # this is a working example of simple substitution. s/%ld /\\stemDown /g s/%lu /\\stemUp /g # persistent forceshift, eg: %s-1.3. Put revert shortcut in .ly s/%s/\\property Voice.NoteColumn \\override #'force-hshift = #/g # add two digits but get one: 16=7 32=5 64=6 and 128=9 # put last so numbers after ``#'' or caps are not affected. :sixteenth /[a-z',]7/{ s/\([a-z',]\)7/\116/ t sixteenth } :thirtysec [a-z',]5/{ s/\([a-z',]\)5/\132/ t thirtysec } :sixtyfourth /[a-z',]6/{ s/\([a-z',]\)6/\164/ t sixtyfourth } :onetwentyeighth /[a-z',]9/{ s/\([a-z',]\)9/\1128/ t onetwentyeighth } # expand {} to { } s/{}/{ }/g =============end ptfilter.sed Consider this next gone. Unless there is a storm of protest, that is. ;-) # substitution of caps in note names, to cut down on typing. Regular # syntax in English can live with this. c c, c,, doesn't change, # but you can write it as c C C, if you like, and F or S can add another # 8ve to C down or c up. Any curly bracket, a double or right quote, # or # before the note will prevent processing it. #cnote s/^Cf/cf,/g s/\([^a-z0-9"{}#']\)Cf/\1cf,/g s/^CF/cf,,/g s/\([^a-z0-9"{}#']\)CF/\1cf,,/g s/^Cs/cs,/g s/\([^a-z0-9"{}#']\)Cs/\1cs,/g s/^CS/cs,,/g s/\([^a-z0-9"{}#']\)CS/\1cs,,/g s/^C/c,/g s/\([^a-z0-9"{}#']\)C/\1c,/g s/^cF/cf'/g s/\([^a-z0-9"{}#']\)cF/\1cf'/g s/^cS/cs'/g s/\([^a-z0-9"{}#']\)cS/\1cs'/g #dnote s/^Df/df,/g s/\([^a-z0-9"{}#']\)Df/\1df,/g s/^DF/df,,/g s/\([^a-z0-9"{}#']\)DF/\1df,,/g s/^Ds/ds,/g s/\([^a-z0-9"{}#']\)Ds/\1ds,/g s/^DS/ds,,/g s/\([^a-z0-9"{}#']\)DS/\1ds,,/g s/^D/d,/g s/\([^a-z0-9"{}#']\)D/\1d,/g s/^dF/df'/g s/\([^a-z0-9"{}#']\)dF/\1df'/g s/^dS/ds'/g s/\([^a-z0-9"{}#']\)dS/\1ds'/g #enote s/^Ef/ef,/g s/\([^a-z0-9"{}#']\)Ef/\1ef,/g s/^EF/ef,,/g s/\([^a-z0-9"{}#']\)EF/\1ef,,/g s/^Es/es,/g s/\([^a-z0-9"{}#']\)Es/\1es,/g s/^ES/es,,/g s/\([^a-z0-9"{}#']\)ES/\1es,,/g s/^E/e,/g s/\([^a-z0-9"{}#']\)E/\1e,/g s/^eF/ef'/g s/\([^a-z0-9"{}#']\)eF/\1ef'/g s/^eS/es'/g s/\([^a-z0-9"{}#']\)eS/\1es'/g #fnote s/^Ff/ff,/g s/\([^a-z0-9"{}#']\)Ff/\1ff,/g s/^FF/ff,,/g s/\([^a-z0-9"{}#']\)FF/\1ff,,/g s/^Fs/fs,/g s/\([^a-z0-9"{}#']\)Fs/\1fs,/g s/^FS/fs,,/g s/\([^a-z0-9"{}#']\)FS/\1fs,,/g s/^F/f,/g s/\([^a-z0-9"{}#']\)F/\1f,/g s/^fF/ff'/g s/\([^a-z0-9"{}#']\)fF/\1ff'/g s/^fS/fs'/g s/\([^a-z0-9"{}#']\)fS/\1fs'/g #gnote s/^Gf/gf,/g s/\([^a-z0-9"{}#']\)Gf/\1gf,/g s/^GF/gf,,/g s/\([^a-z0-9"{}#']\)GF/\1gf,,/g s/^Gs/gs,/g s/\([^a-z0-9"{}#']\)Gs/\1gs,/g s/^GS/gs,,/g s/\([^a-z0-9"{}#']\)GS/\1gs,,/g s/^G/g,/g s/\([^a-z0-9"{}#']\)G/\1g,/g s/^gF/gf'/g s/\([^a-z0-9"{}#']\)gF/\1gf'/g s/^gS/gs'/g s/\([^a-z0-9"{}#']\)gS/\1gs'/g #anote s/^Af/af,/g s/\([^a-z0-9"{}#']\)Af/\1af,/g s/^AF/af,,/g s/\([^a-z0-9"{}#']\)AF/\1af,,/g s/^As/as,/g s/\([^a-z0-9"{}#']\)As/\1as,/g s/^AS/as,,/g s/\([^a-z0-9"{}#']\)AS/\1as,,/g s/^A/a,/g s/\([^a-z0-9"{}#']\)A/\1a,/g s/^aF/af'/g s/\([^a-z0-9"{}#']\)aF/\1af'/g s/^aS/as'/g s/\([^a-z0-9"{}#']\)aS/\1as'/g #bnote s/^Bf/bf,/g s/\([^a-z0-9"{}#']\)Bf/\1bf,/g s/^BF/bf,,/g s/\([^a-z0-9"{}#']\)BF/\1bf,,/g s/^Bs/bs,/g s/\([^a-z0-9"{}#']\)Bs/\1bs,/g s/^BS/bs,,/g s/\([^a-z0-9"{}#']\)BS/\1bs,,/g s/^B/b,/g s/\([^a-z0-9"{}#']\)B/\1b,/g s/^bF/bf'/g s/\([^a-z0-9"{}#']\)bF/\1bf'/g s/^bS/bs'/g s/\([^a-z0-9"{}#']\)bS/\1bs'/g