Commit 3a47c6f3 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Handle all clef types

-) For mensural clefs, write out a warning that MusicXML does not support them
-) Move all clef-generation to a dedicated clef (..) function
-) Also implement g-2 clef (tenor clef)
parent 2610a3bd
......@@ -160,20 +160,12 @@ sub parse_pe {
$pe =~ s/@/@0/gs; # make missing time signature explicit
while ($pe =~ s/([^\-])(\d+)(\'|\,)(A|B|C|D|E|F|G)/$1$3$2$4/gs) {}; # octave first, then duration. Truly global.
if ($pe =~ /\s*(%([\w\-\d]+))?(@([\d\w\/]+))?\s*&?\s*(\$([^]+))?(.*)$/gs) {
if ($pe =~ /\s*(%([\w\-\+\d]+))?(@([\d\w\/]+))?\s*&?\s*(\$([^]+))?(.*)$/gs) {
my ($clef, $timesig, $keysig, $rest) = ($2, $4, $6, $7);
print "Writing $filename...\n";
open(OUT, ">$filename");
if ($clef =~ /^(\w)\-(\d)$/) {
($clefsign, $clefline) = ($1, $2);
} else {
($clefsign, $clefline) = ("G", 2);
}
$timesig = timesignature($timesig);
my %fif=("", 0, "xF", 1, "xFC", 2, "xFCG",3, "xFCGD",4, "xFCGDA",5, "xFCGDAE",6, "xFCGDAEB",7, "bB",-1, "bBE",-2, "bBEA",-3, "bBEAD",-4, "bBEADG",-5, "bBEADGC",-6, "bBEADGCF",-7);
$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.
......@@ -214,12 +206,9 @@ sub parse_pe {
<key>
<fifths>'.$fifths.'</fifths>
</key>
'.$timesig
.' <clef>
<sign>'.$clefsign.'</sign>
<line>'.$clefline.'</line>
</clef>
</attributes>
'.timesignature($timesig)
.clef ($clef)
.' </attributes>
';
......@@ -371,17 +360,12 @@ sub parse_notes {
<actual-notes>'.$act_notes.'</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>', $qq);
} elsif ($notes =~ /^(%\w-\d)(.*)$/) { # Clef change
($clef,$notes) = ($1,$2);
$clef =~ /^%(\w)\-(\d)$/;
($clefsign, $clefline) = ($1, $2);
print OUT ' <attributes>
<clef>
<sign>'.$clefsign.'</sign>
<line>'.$clefline.'</line>
</clef>
</attributes>
';
} elsif ($notes =~ /^(%(\w(-|\+)\d))(.*)$/) { # Clef change
($clef,$notes) = ($2,$4);
$clef = clef ($clef);
print OUT " <attributes>\n";
print OUT $clef;
print OUT " </attributes>\n";
} elsif ($notes =~ /^@(\d\/\d|c\/?)\s*(.*)$/) { # time signatue change
# print "$notes\n";
($timesig,$notes) = ($1,$2);
......@@ -618,6 +602,28 @@ sub octave {
return $old_octave;
}
sub clef {
my ($clef) = @_;
my $clefoctave = '';
if ($clef =~ /^(\w)(\-|\+)(\d)$/) {
($clefsign, $clefline) = ($1, $3);
if ($2 =~ /^\+$/) {
print "Warning: Mensural clefs are not supported by MusicXML, using modern clef (input: $clef)\n";
}
if ($clefsign eq 'g') {
$clefsign = "G";
$clefoctave = " <clef-octave-change>-1</clef-octave-change>\n";
}
} else {
($clefsign, $clefline) = ("G", 2);
}
return ' <clef>
<sign>'.$clefsign.'</sign>
<line>'.$clefline.'</line>
'.$clefoctave.' </clef>
';
}
sub timesignature {
my ($timesig) = @_;
......
Test Composer
Test case for clefs
1.1.1: S Clefs
plain&easy: %G-2@c$bB '1C/%G-4 1C/2D%C-1 2E/%F-4 1C/%g-21 C/%C+3 1C/
Test Library
00000000
\ No newline at end of file
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