------- octly.txt (c)2003David Raleigh Arnold, under GNU. Enjoy! Enclosed is a list of sed commands which may be put into a separate file, prehaps octly.sed, to use sed to transpose lilypond notes (english.ly) up or down octaves. The input file has to be edited and the markers typed in. Markers come in pairs which begin and end and apply to the whole line in which they appear and all lines between. There may be weirdness if there is any overlapping or an incomplete pair, because each pass with sed removes one of each of these markers per line, and sed in this case is addressing ranges of lines. You can process notes and read them into an .ly file or process a whole .ly file, but remember that this works by the line and not by the measure. The commands disappear, but you could use comments to make it possible to run lilypond on the file without or before performing all of the transpositions. "d" and "u" are down and up, "8" is one octave, "82" is two, "84" is four, and "e" indicates the ending marker. To raise an octave: @8u raises this line .... raises this line ... @e8u raises this line To lower two octaves: ... % @82d ... @e82d Three octaves up. Keep the same ranges on the same lines, but the order doesn't matter: @82u @8u ... @e8u @e82u Four octaves down: @84d ... @e84d Duplicates in the same range would require another pass on the file. but with combinations or 1, 2, and 4 octaves you can get up to seven: 3=1+2, 5=1+4, 6=2+4, and 7=1+2+4. Surely that is more than sufficient? Call octly.sed this way: sed -f ~/bin/octly.sed inputfile.ly (to dump) or sed -f ~/bin/octly.sed inputfile.ly > outputfile.ly I believe dos-windows would be: sed -f \bat\octly.sed inputfile.ly Sorry, you have to give the whole path for octly.sed. Of course you could call it with a bash script or batch file, but if you put it inside a bash executable script instead, you must replace the ' single quote in the search string with '\'' a single-quoted escaped single quote. I don't know about any dos batfile gotchas with sed. If you don't have sed, you can easily get it. The main purpose of this is to fix mistakes in a way so that you will be able to understand the resulting lilypond source.ly years later. For example, you're sorry you wrote it for flute rather than piccolo. A short passage should be an octave lower for one instrument or higher for another. Lilypond has a perfectly good \transpose function, but it stays in the file and keeps looking at you. Take the comments out if your version of sed does not permit them. Write the rest of this file as octly.sed: # octly.sed (c)2003David Raleigh Arnold, under GNU. Enjoy! # specifying a range of addresses: /@8d/,/@e8d/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@8d//1 # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # delete the corresponding closing marker(s) s/@e8d//1 } # specifying a range of addresses: /@8u/,/@e8u/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@8u//1 # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # delete closing marker(s) s/@e8u//1 } # start doubles.... # specifying a range of addresses: /@82d/,/@e82d/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@82d//1 # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # delete the corresponding closing marker(s) s/@e82d//1 } # specifying a range of addresses: /@82u/,/@e82u/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@82u//1 # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # delete closing marker(s) s/@e82u//1 } # start quadruples: # specifying a range of addresses: /@84d/,/@e84d/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@84d//1 # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\)'/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1,/g s/@protect@//g # delete the corresponding closing marker(s) s/@e84d//1 } # specifying a range of addresses: /@84u/,/@e84u/{ # these five lines get rid of tabs and extra spaces and put a space # before each line and before every note (I hope). # The next line must contain a tab: s/tab/space/g. s/ / /g s/^ */ /g s/[]~)(}{><][])(}{><]*/& /g s/^ */ /g s/ */ /g # delete one opening marker from each line s/@84u//1 # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # transpose the notes s/ \([a-g][sf!?]*\),/ @protect@\1/g s/ \([a-g][sf!?]*\)/ @protect@\1'/g s/@protect@//g # delete closing marker(s) s/@e84u//1 }