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