Hi.

> Does anyone have any ideas about how to get a list of all the pitches from a
> score? ... besides just counting off the sheet music.
> Even better, to get a count of how many times each of the used notes are 
> played.
Here is a Perl script that counts the notes in LilyPond files (only the
English pitch names).
Example usage:
    countLilyNotes.pl *.ly


Best,
Gilles
#!/usr/bin/perl -w

use IO::File;

my $lilyRE = '\b([a-gs](is|es){0,2})(\d|\b)';

my %counters = ();

for my $f (@ARGV) {
    my $io = IO::File->new($f);

    while ($_ = $io->getline) {
        chomp;
    
        my $note;
        while (($note) = /$lilyRE/o) {
            s/^.*?$note//;
            $counters{$note}++;
        }
    }
}

my $total = 0;

foreach (keys %counters) {
    $total += $counters{$_};
}

my %percent = ();

foreach (keys %counters) {
    $percent{$_} = $counters{$_} / $total * 100;
}

foreach (keys %counters) {
    print $_, '=', $counters{$_}, ' (';
    printf "%.2f", $percent{$_};
    print '%)', "\n" ;
}

print "Total=$total\n";
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to