# keys.sed 
# Writes chromatics for *single letter* notes, according to user flag,
# to save typing.  There is *no* transposition. 
# Uses b for flat, w for double flat. s and x 
# Use 'n' for natural to prevent alteration, b included. no h.
# Writes in "international.ly" form. intl.sed can convert to english.ly
# Put KEY[1-7][bs] anywhere on first line to edit and new key anywhere
# on any line to change keys. KEY0 ends processing.
# examples: KEY4s = E major. KEY3b = Eb major.  KEY0 = A minor ;-)
# (c)2005 David Raleigh Arnold. -->GNU Enjoy! rev. 20080116

# no tabs
s/\t/ /g

# space follows/precedes curly, pointer, to prettify.
s/[{<]/ & /g
s/[}>]/ &/g

# put spaces at begin and end of line, double spaces inside
# to simplify
s/^ */ /
s/ *$/ /
s/  */  /g

# make the following into a conversion script:
# change spellings. Notes must follow at least one space.
# not relevant to key, user preference thing:
#
#   b and bb notes to f and ff
# if this changes,single letter marking must also
#s/\( [a-g]\)bb/\1ff/g
#s/\( [a-g]\)b/\1f/g
#   h to b-natural
#  todo: not followed by
#s/ h/ bn/g
#   w to double flat ff
# if this changes,single letter marking must also
#s/\( [a-g]\)w/\1ff/g

# key range
/Key[1-7][bs]/,/Key0/{

# mark single letter notes only. Accidentals will
# be added as they fall into the right key.

s/\( [a-g]\)\([^wbnxs]\)/\1%flatORsharp%\2/g

# goto (branch) and fall through
/Key7b/,/Key0/b keycb
/Key6b/,/Key0/b keygb
/Key5b/,/Key0/b keydb
/Key4b/,/Key0/b keyab
/Key3b/,/Key0/b keyeb
/Key2b/,/Key0/b keybb
/Key1b/,/Key0/b keyfn
/Key7s/,/Key0/b keycs
/Key6s/,/Key0/b keyfs
/Key5s/,/Key0/b keybn
/Key4s/,/Key0/b keyen
/Key3s/,/Key0/b keyan
/Key2s/,/Key0/b keydn
/Key1s/,/Key0/b keygn 

:keycb
s/f%flatORsharp%/f%flat%/g
:keygb
s/c%flatORsharp%/c%flat%/g
:keydb
s/g%flatORsharp%/g%flat%/g
:keyab
s/d%flatORsharp%/d%flat%/g
:keyeb
s/a%flatORsharp%/a%flat%/g
:keybb
s/e%flatORsharp%/e%flat%/g
:keyfn
s/b%flatORsharp%/b%flat%/g
b finish

:keycs
s/b%flatORsharp%/b%sharp%/g
:keyfs
s/e%flatORsharp%/e%sharp%/g
:keybn 
s/a%flatORsharp%/a%sharp%/g
:keyen 
s/d%flatORsharp%/d%sharp%/g
:keyan 
s/g%flatORsharp%/g%sharp%/g
:keydn 
s/c%flatORsharp%/c%sharp%/g
:keygn 
s/f%flatORsharp%/f%sharp%/g

:finish
# leaving out next line for debugging;
s/%flatORsharp%//g
# only b's and s's are added, since no 
# others are in key signatures
        
# flat is b
s/%flat%/b/g
# sharp is s
s/%sharp%/s/g
}

# Now outside of curly. clean up. Getting rid of n's, Key, Key0:
s/\( [a-g]\)n/\1/g
s/KEY[1-7][bs]//g
s/KEY0//g

# Undo formatting, (except bar-letter. ???)
s/{ */{/g
s/< */</g
s/ *>/>/g
s/ *}/}/g

# undo spaces at begin and end of line, double space inside
s/^ *//
s/*$//
s/  */ /g

Regards, daveA

-- 
For beginners: very easy guitar music, solos, duets, exercises. Early
intermediate guitar solos. One best scale set for all guitarists.
http://www.openguitar.com/scalescomparison.html ::: plus new and
better chord and arpeggio exercises.  http://www.openguitar.com 


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to