Commit ab05eb52 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Indentation consistency (one tab in the MusicXML file, two spaces for code)

parent 03bafbc8
......@@ -93,8 +93,10 @@ sub parse_pe {
$keysig =~ s/(\s+)|&//gs; # it is unclear what the & means, so we'll ignore it for now.
$keysig =~ s/\[|\]//gs; # IGNORING brackets around a key sig.
$fifths = $fif{$keysig};
if ($fifths eq "") { $fifths = "0";
print_error("Strange key signature '$keysig'.\n");}
if ($fifths eq "") {
$fifths = "0";
print_error("Strange key signature '$keysig'.\n");
}
foreach $_ ($rismsig,$title,$inr,$instr,$comp,$encoding_date,$libsig,$sonst)
{
......@@ -105,18 +107,18 @@ sub parse_pe {
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 0.6 Partwise//EN" "file:/c:/Program Files/MusicXML/partwise.dtd">
<score-partwise>
<work>
<work-number>'.$rismsig.'</work-number>
<work-number>'.$rismsig.'</work-number>
<work-title>'.$title.'</work-title>
</work>
<movement-number>'.$inr.'</movement-number>
<movement-title>'.$instr.'</movement-title>
<movement-number>'.$inr.'</movement-number>
<movement-title>'.$instr.'</movement-title>
<identification>
<creator type="composer">'.$comp.'</creator>
<encoding>
<software>pae2xml by R. Typke</software>
<encoding-date>'.$encoding_date.'</encoding-date>
</encoding>
<source>'.$libsig.'</source>
<source>'.$libsig.'</source>
</identification>
<part-list>
<score-part id="P1">
......@@ -130,8 +132,8 @@ sub parse_pe {
<key>
<fifths>'.$fifths.'</fifths>
</key>
'.$timesig.'
<clef>
'.$timesig
.' <clef>
<sign>'.$clefsign.'</sign>
<line>'.$clefline.'</line>
</clef>
......@@ -149,7 +151,7 @@ REST: $rest\n";
parse_notes($rest, $keysig);
}
else { print_error("could not parse $pe\n"); }
print OUT " </part>
print OUT " </part>
</score-partwise>\n";
close OUT;
}
......@@ -207,7 +209,7 @@ sub parse_notes {
$measrest = $1;
$notes = $2;
if ($measrest eq '') {
$measrest = 1;
$measrest = 1;
}
$toprint .= "$measrest measures of rest.\n";
if ($measrest > 0) {
......@@ -224,20 +226,18 @@ sub parse_notes {
print OUT ' <note>
<rest />
<duration>'.($beats*$divisions*4/$beattype).'</duration>
'.# <type>quarter</type>
'
</note>
';
if ($n < $measrest) {
print OUT " </measure>\n";
if ($notes ne "") {
print OUT ' <measure number="'.$meas.'">
if ($n < $measrest) {
print OUT " </measure>\n";
if ($notes ne "") {
print OUT ' <measure number="'.$meas.'">
';
$meas++;
} else {
$mopen = 0;
}
}
$meas++;
} else {
$mopen = 0;
}
}
}
} elsif ($notes =~ /^((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/) { # a note
($note, $notes) = ($1,$6);
......@@ -280,9 +280,9 @@ sub parse_notes {
<normal-notes>1</normal-notes>
</time-modification>', $qq);
while ($tuplet =~ /^((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.+)$/gs) {
($note, $tuplet) = ($1,$6);
#print "$note / $tuplet\n";
parse_note($note, $keysig, '', ' <time-modification>
($note, $tuplet) = ($1,$6);
#print "$note / $tuplet\n";
parse_note($note, $keysig, '', ' <time-modification>
<actual-notes>'.$act_notes.'</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>', $qq);
......@@ -346,11 +346,11 @@ sub parse_notes {
<repeat direction="forward"/>
</barline>
';
}
print OUT $clefattr;
$meas++;
}
print OUT $clefattr;
$meas++;
} else {
$mopen = 0;
$mopen = 0;
}
$toprint .= "bar line\n";
} #elsif ($notes =~ /^(\d*\.*\-)(.*)$/) {
......@@ -371,8 +371,7 @@ sub parse_notes {
print OUT ' <note>
<rest />
<duration>'.($beats*$divisions*4/$beattype).'</duration>
'.# <type>quarter</type>
' <notations>
<notations>
<fermata type="upright"/>
</notations>
</note>
......@@ -417,21 +416,20 @@ sub parse_note {
print OUT ' <note>
';
if ($gracecue eq "g") {
print OUT ' <grace steal-time-following="33"/>
print OUT ' <grace steal-time-following="33"/>
';
}
if ($gracecue eq "q" || $in_qq_group) {
print OUT ' <cue/>
print OUT ' <cue/>
';
}
if ($pitch eq "-") {
print OUT " <rest />\n";
print OUT " <rest />\n";
} else {
print OUT ' <pitch>
<step>'.$pitch.'</step>
'.
alter($pitch, $acc, $keysig).'
<octave>'.octave($oct).'</octave>
'.alter($pitch, $acc, $keysig)
.' <octave>'.octave($oct).'</octave>
</pitch>
';
}
......@@ -439,17 +437,16 @@ sub parse_note {
print OUT ' <duration>'.(duration($dur, $dot)*$normalnotes/$actualnotes).'</duration>
';
}
# <type>quarter</type>
if ($tie eq "+") {
if (!$TIE) {
$TIE = 1;
print OUT '<tie type="start"/>
print OUT ' <tie type="start"/>
';
}
} else {
if ($TIE) {
print OUT '<tie type="stop"/>
print OUT ' <tie type="stop"/>
';
$TIE = 0;
}
......@@ -499,7 +496,7 @@ sub alter {
}
if ($alt != 0) {
return "<alter>$alt</alter>\n";
return "\t\t\t\t\t<alter>$alt</alter>\n";
}
return "";
}
......@@ -552,43 +549,43 @@ sub timesignature {
}
if ($timesig eq "0" || $timesig eq "") { # unclear how to handle absence of time signature.
$timesig ='<time symbol="common">
<beats>4</beats>
<beat-type>4</beat-type>
</time>
$timesig =' <time symbol="common">
<beats>4</beats>
<beat-type>4</beat-type>
</time>
'; # using 4/4 for now.
($beats, $beattype) = (4,4);
} elsif ($timesig =~ /^c(\/?)$/gi) {
if ($1 eq "/") {
$timesig = '<time symbol="cut">
<beats>2</beats>
<beat-type>2</beat-type>
</time>
$timesig = ' <time symbol="cut">
<beats>2</beats>
<beat-type>2</beat-type>
</time>
';
($beats, $beattype) = (2,2);
} else {
$timesig = '<time symbol="common">
<beats>4</beats>
<beat-type>4</beat-type>
</time>
$timesig = ' <time symbol="common">
<beats>4</beats>
<beat-type>4</beat-type>
</time>
';
($beats, $beattype) = (4,4);
}
} elsif ($timesig =~ /^(\d+)\/(\d+)$/gs) {
($beats, $beattype) = ($1, $2);
$timesig = '<time>
<beats>'.$beats.'</beats>
<beat-type>'.$beattype.'</beat-type>
</time>
$timesig = ' <time>
<beats>'.$beats.'</beats>
<beat-type>'.$beattype.'</beat-type>
</time>
';
} else {
print_error("Time signature '$timesig' looks strange.\n");
# $timesig = ""; we assume 4/4 just to get something legible:
($beats, $beattype) = (4,4);
$timesig = '<time>
<beats>'.$beats.'</beats>
<beat-type>'.$beattype.'</beat-type>
</time>
$timesig = ' <time>
<beats>'.$beats.'</beats>
<beat-type>'.$beattype.'</beat-type>
</time>
';
}
return $timesig;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment