lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

petals


From: David Raleigh Arnold
Subject: petals
Date: Sun, 13 Jan 2002 19:14:16 -0600 (CST)
User-agent: IMP/PHP IMAP webmail program 2.2.5

Since nothing came back, I will try again. :-) Sorry about the wrapping.

#!/bin/bash
#--verbose
# petals ver 020113. Needs GNU gawk, bash with a read command that works. 
# arg1 is the name of the file with notes in it.
if [ $# -ne 1 -o ! -f "$1" ]
then
echo "petals (c)2002 David Raleigh Arnold free under GNU etc etc etc."
echo "This program is trivial, and based on a very few GNU gawk commands. It"
echo "helps make large creative projects practical with lilypond."
echo ""
echo "   Usage:  ./petals notesfile"
echo "     * Prints the number of voices in each measure in the file."
echo "     * Splits your petals score, notesfile, into parts for lilypond."
echo ""
echo "\notes { \boilerplate(stuff) \include \"mymasterpiece-pt2.ly\" }"
echo ""
echo "A line in notesfile is a measure and a voice or part is a column."
echo "Field separator: {FS=\";\"}"
echo "Record separator {RS=\"\n\"} by default a new line."
echo ""
echo "             This is 3 measures of a valid 4 part score:"
echo "" 
echo "g'2 g' %vocal ; e'''1   %piccolo ; First -- %lyrics     ; g,,1 %tuba"    
echo "\skip 1       ; \skip 1          ; @macro %filter this! ; \oompah %ly 
macro"
echo "\mf %meas fill ; c'' %piccolo ; sing ; \mf %better to align all parts..."
echo ""
echo "This program checks the validity of your score completely, but it does 
not"
echo "check its content. This, you will quickly discover, is a good thing. Your"
echo "masterpiece.ly file should not contain any notes."
exit 0
fi

# checking errors for user.
echo ""
echo "     ======== Report on" $1 "score-file. ========" > $1.rpt
# to screen first, just in case...
gawk 'BEGIN {FS=";"}{print "Record (measure) number " NR " contains " NF "
fields (parts, voices)."}' $1
gawk 'BEGIN {FS=";"}{print "Record (measure) number " NR " contains " NF "
fields (parts, voices)."}' $1 >> $1.rpt
# number of fields in the 1st record.
gawk 'BEGIN {FS=";"}{ print NF }' $1 > numvoices.gub 
# read it into a variable. It only takes 1st line of file.
read fldnum < numvoices.gub
# clean up
rm numvoices.gub
echo ""
echo "You are scoring for" $fldnum "voices." $fldnum "voices will be extracted
from your score,"
echo $1"."  "$1.rpt contains the number of voices in each measure of"
echo "your petals score, assuming that each line of the score is a measure."
echo ""
# clobber old $1-ptn.ly files."
echo "Clobbering the old" $1"-ptn.ly files. An error means there were none."
rm $1-pt*
echo ""
# a little humor.
echo "Making your parts. Please wait..........."
echo ""
# 'gawk' is *wonderful*, but it doesn't take bash arguments in a 
straightforward way
# in the same file. (or does it?) $1 in {print $1} is not the same as $1 
elsewhere.

if [ $fldnum -ge 1 ]
then
gawk 'BEGIN {FS=";"}{print $1}' $1 > $1-pt1.ly
fi

if [ $fldnum -ge 2 ]
then
gawk 'BEGIN {FS=";"}{print $2}' $1 > $1-pt2.ly
fi

if [ $fldnum -ge 3 ]
then
gawk 'BEGIN {FS=";"}{print $3}' $1 > $1-pt3.ly
fi

if [ $fldnum -ge 4 ]
then
gawk 'BEGIN {FS=";"}{print $4}' $1 > $1-pt4.ly
fi

if [ $fldnum -ge 5 ]
then
gawk 'BEGIN {FS=";"}{print $5}' $1 > $1-pt5.ly
fi

if [ $fldnum -ge 6 ]
then
gawk 'BEGIN {FS=";"}{print $6}' $1 > $1-pt6.ly
fi

if [ $fldnum -ge 7 ]
then
gawk 'BEGIN {FS=";"}{print $7}' $1 > $1-pt7.ly
fi

if [ $fldnum -ge 8 ]
then
gawk 'BEGIN {FS=";"}{print $8}' $1 > $1-pt8.ly
fi

if [ $fldnum -ge 9 ]
then
gawk 'BEGIN {FS=";"}{print $9}' $1 > $1-pt9.ly
fi

if [ $fldnum -ge 10 ]
then
gawk 'BEGIN {FS=";"}{print $10}' $1 > $1-pt10.ly
fi

if [ $fldnum -ge 11 ]
then
gawk 'BEGIN {FS=";"}{print $11}' $1 > $1-pt11.ly
fi

if [ $fldnum -ge 12 ]
then
gawk 'BEGIN {FS=";"}{print $12}' $1 > $1-pt12.ly
fi

if [ $fldnum -ge 13 ]
then
gawk 'BEGIN {FS=";"}{print $13}' $1 > $1-pt13.ly
fi

if [ $fldnum -ge 14 ]
then
gawk 'BEGIN {FS=";"}{print $14}' $1 > $1-pt14.ly
fi

if [ $fldnum -ge 15 ]
then
gawk 'BEGIN {FS=";"}{print $15}' $1 > $1-pt15.ly
fi

if [ $fldnum -ge 16 ]
then
gawk 'BEGIN {FS=";"}{print $16}' $1 > $1-pt16.ly
fi

if [ $fldnum -ge 17 ]
then
gawk 'BEGIN {FS=";"}{print $17}' $1 > $1-pt17.ly
fi

if [ $fldnum -ge 18 ]
then
gawk 'BEGIN {FS=";"}{print $18}' $1 > $1-pt18.ly
fi

if [ $fldnum -ge 19 ]
then
gawk 'BEGIN {FS=";"}{print $19}' $1 > $1-pt19.ly
fi

if [ $fldnum -ge 20 ]
then
gawk 'BEGIN {FS=";"}{print $20}' $1 > $1-pt20.ly
fi

if [ $fldnum -ge 21 ]
then
gawk 'BEGIN {FS=";"}{print $21}' $1 > $1-pt21.ly
fi

if [ $fldnum -ge 22 ]
then
gawk 'BEGIN {FS=";"}{print $22}' $1 > $1-pt22.ly
fi

if [ $fldnum -ge 23 ]
then
gawk 'BEGIN {FS=";"}{print $23}' $1 > $1-pt23.ly
fi

if [ $fldnum -ge 24 ]
then
gawk 'BEGIN {FS=";"}{print $24}' $1 > $1-pt24.ly
fi

if [ $fldnum -ge 25 ]
then
gawk 'BEGIN {FS=";"}{print $25}' $1 > $1-pt25.ly
fi

if [ $fldnum -ge 26 ]
then
gawk 'BEGIN {FS=";"}{print $26}' $1 > $1-pt26.ly
fi

if [ $fldnum -ge 27 ]
then
gawk 'BEGIN {FS=";"}{print $27}' $1 > $1-pt27.ly
fi

if [ $fldnum -ge 28 ]
then
gawk 'BEGIN {FS=";"}{print $28}' $1 > $1-pt28.ly
fi

if [ $fldnum -ge 29 ]
then
gawk 'BEGIN {FS=";"}{print $29}' $1 > $1-pt29.ly
fi

if [ $fldnum -ge 30 ]
then
gawk 'BEGIN {FS=";"}{print $30}' $1 > $1-pt30.ly
fi

# if 30 parts are not enough, just add if blocks above.
# if you want to use fewer parts, comment some out.
echo "Parts written. You have" $fldnum "(limited to 30) new parts."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]