[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting a list of all pitches used in a score
From: |
Gilles Sadowski |
Subject: |
Re: Getting a list of all pitches used in a score |
Date: |
Thu, 28 Aug 2008 22:40:58 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hi.
> I am unable to get the attachment (I get http error 404). What am I missing?
A possible explanation was given in another post.
In any case, here is the script inline (just copy/paste the text between
the "---CUT---" marks in another file):
---CUT---
#!/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";
---CUT---
Best,
Gilles
Re: Getting a list of all pitches used in a score, Dmytro O. Redchuk, 2008/08/28