use XML::LibXML;
use File::Basename;
use IO::File;
-
use v5.10;
+use utf8;
our %half = ( # decode from one note length to its half
- # there may be mispellings, as I can't be bothered
- # to look at the code, as I use this for early music
-
qw(
+ maxima long
long breve
breve whole
whole half
half quarter
quarter eighth
- eighth sixteenth
- sixteenth thirtysecond
- thirtysecond sixtyfourth
+ eighth 16th
+ 16th 32nd
+ 32nd 64th
+ 64th 128th
+ 128th 256th
+ 256th 512th
+ 512th 1024th
)
);
our %yesno = ( qw(yes 1 no 0) ); # used for turning translating yes/no text values
usage() unless @ARGV;
+binmode STDOUT, "utf8";
+
foreach my $fn (@ARGV) {
my ($name, $path, $suffix) = fileparse($fn, qr/\.[^.]*/);
my ($ifn, $ofn);
my $syllabic = 0; # track syllabic mode (whether we are in the middle of a word in lyrics).
display($staff) if $dbg;
foreach my $measure ($staff->findnodes('./Measure')) {
-
+ my $lens;
+
+ # obtain the measure no and any len attr. Change the len attribute
+ my ($l) = $measure->findnodes('./@len');
+ if ($l) {
+ my ($t,$b) = split m{/}, $l->to_literal;
+ $b *= 2;
+ $lens = "$t/$b";
+ $l->setValue($lens);
+ }
# process nodes
foreach my $node ($measure->findnodes('./*')) {
if ($node->nodeType == XML_ELEMENT_NODE) {
my ($nz) = $node->findnodes('./duration/@z');
my ($nn) = $node->findnodes('./duration/@n');
my $was = $nn->to_literal;
- my $now = $sigD || $was * 2;
+ my $now = $was * 2;
my $z = $nz->to_literal;
display($staff, $measure, $node, "$type $z/$was -> $z/$now") if $dbg;
$nn->setValue($now);
}
# determine where we are in a word and if there is a <syllabic>
- # clause, and it is necessary, add an appropriate one
+ # clause, note its value (which is "in word" or "not in word")
#
# This is for dealing with musicxml imports where there is no
- # explicit detection of trailing '-' signs, if there are and
- # there is no <syllabic> add one of the correct sort and remove
+ # explicit detection of trailing '-' signs, if there are such signs and
+ # there is no <syllabic> clause, add one of the correct sort and remove
# any trailing '-' from the text.
#
- # Sadly, it's too much hard work to deal with trailing '_' 'cos
+ # Sadly, it's too much hard work to deal with any trailing '_' 'cos
# mscore calulates the distance in advance because they appear
# to be too lazy to have another <syllabic> state to deal with
# it. Manual edit will therefore be required. Hopefully, not
my $newv;
my $newstate;
my $newtext = $v;
- if ($v =~ /-$/) {
+ if ($v =~ /[-–]$/) {
$newv = 'begin' unless $syllabic;
$newv = 'middle' if $syllabic;
$newstate = 1;
- $newtext =~ s/\-+$//;
+ $newtext =~ s/[-–]+$//;
} else {
$newv = 'end' if $syllabic;
$newstate = 0;