diff --git a/pae2xml.pl b/pae2xml.pl index 5b994554c82ba00d4394d92d4958b0bcb9c5cd26..7df2f2436ff68b48ed120776ed5791c6d4ca431d 100755 --- a/pae2xml.pl +++ b/pae2xml.pl @@ -253,6 +253,7 @@ sub parse_notes { $notes =~ s/(\.|\d|\,|\')qq/qq$1/gs; # pull beginning mark of group of grace notes in front of corresponding notes $notes =~ s/(xx|x|bb|b|n)qq/qq$1/gs; # qq first, then parts of notes + $notes =~ s/([\.\d,'xbn])+(q|g)/$2$1/gs; # q and g first, then parts of notes while ($notes ne "") { if ($notes =~ /^(\'+|\,+)(.*)$/) { # Octave marks @@ -299,23 +300,23 @@ sub parse_notes { } } } - } elsif ($notes =~ /^((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/) { # a note + } elsif ($notes =~ /^((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/) { # a note ($note, $notes) = ($1,$6); parse_note($note, $keysig, "", "", $qq); - } elsif ($notes =~ /^(\((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)[t\+]*\)[t\+]*)(.*)$/) { # one note with a fermata + } elsif ($notes =~ /^(\((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)[t\+]*\)[t\+]*)(.*)$/) { # one note with a fermata ($note, $notes) = ($1,$6); parse_note($note, $keysig, "", "", $qq); - } elsif ($notes =~ /^(\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?){3}\))(.*)$/) { # a triplet + } elsif ($notes =~ /^(\(((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?){3}\))(.*)$/) { # a triplet ($triplet, $notes) = ($1,$7); # print "TRIPLET: ".$triplet." -> "; - $triplet =~ /^\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.*)\)$/gs; + $triplet =~ /^\(((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)(.*)\)$/gs; ($note, $triplet) = ($1,$6); #print "$note $triplet\n"; parse_note($note, $keysig, '<tuplet type="start"/>', ' <time-modification> <actual-notes>3</actual-notes> <normal-notes>2</normal-notes> </time-modification>', $qq); - $triplet =~ /^((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/gs; + $triplet =~ /^((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/gs; ($note, $triplet) = ($1,$6); #print "$note $triplet\n"; parse_note($note, $keysig, '', ' <time-modification> @@ -326,7 +327,7 @@ sub parse_notes { <actual-notes>3</actual-notes> <normal-notes>2</normal-notes> </time-modification>', $qq); - } elsif ($notes =~ /^((\d+)\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)+\;(\d+)\))(.*)$/) { # an n-tuplet + } elsif ($notes =~ /^((\d+)\(((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)+\;(\d+)\))(.*)$/) { # an n-tuplet ($tuplet, $notes) = ($1,$9); # print "N-TUPLET: ".$tuplet." -> "; $tuplet =~ /^(\d+)\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)(.*);(\d)\)$/gs; @@ -339,7 +340,7 @@ sub parse_notes { <actual-notes>'.$act_notes.'</actual-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) { + while ($tuplet =~ /^((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)(.+)$/gs) { ($note, $tuplet) = ($1,$6); #print "$note / $tuplet\n"; parse_note($note, $keysig, '', ' <time-modification> @@ -434,7 +435,7 @@ sub parse_notes { </note> '; } - elsif ($notes =~ s/(\d+\.*)\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?)\)/\($1$2\)/gs) { # pull duration into fermata parentheses + elsif ($notes =~ s/(\d+\.*)\(((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)\)/\($1$2\)/gs) { # pull duration into fermata parentheses # print "after replacement: $notes\n"; exit; } elsif ($notes =~ /^ +(.*)$/) { @@ -468,13 +469,13 @@ sub parse_note { $fermata = 1; } - $note =~ /^((\,|\')*)(x|xx|b|bb|n)?(\d*)(\.*)(g|q)?(\-|A|B|C|D|E|F|G)(t?)(\+?)$/; - my ($oct, $acc, $dur, $dot, $gracecue, $pitch, $trill, $tie) = ($1, $3, $4, $5, $6, $7, $8, $9); + $note =~ /^(g|q)?((\,|\')*)(x|xx|b|bb|n)?(\d*)(\.*)(\-|A|B|C|D|E|F|G)(t?)(\+?)$/; + my ($gracecue, $oct, $acc, $dur, $dot, $pitch, $trill, $tie) = ($1, $2, $4, $5, $6, $7, $8, $9); print OUT ' <note> '; if ($gracecue eq "g") { - print OUT ' <grace steal-time-following="33"/> + print OUT ' <grace slash="yes" steal-time-following="33"/> '; } if ($gracecue eq "q" || $in_qq_group) { @@ -516,8 +517,12 @@ sub parse_note { } } - # Determine graphic notehead: - print OUT notehead ($dur, $dot); + # Determine graphic notehead: acciaccaturas are always 8th, otherwise use duration + if ($gracecue eq "g") { + print OUT " <type>eighth</type>\n"; + } else { + print OUT notehead ($dur, $dot); + } # If we have an explicit accidental on the note, print the <accidental> tag print OUT accidental_explicit ($acc); diff --git a/sample_files/Grace-acciaccatura.pae b/sample_files/Grace-acciaccatura.pae new file mode 100644 index 0000000000000000000000000000000000000000..779645d0c071c3c41fa0bf3f9783d1bb01902d37 --- /dev/null +++ b/sample_files/Grace-acciaccatura.pae @@ -0,0 +1,7 @@ +Test Composer +Test case for acciaccatura +1.1.1: S acciaccatura +plain&easy: %G-2@c� '2Ag''C{8D'B}''4C/'2A''xgC{8D'B}''4C/ + +Test Library +00000000 \ No newline at end of file