computers · music

How Many Notes in Mozart’s Requiem?

When some bright spark suggests a ‘how many notes in the score’ competition, I thought what piece could be better than Mozart’s Requiem?  4 choral parts, orchestra, I could have the vocal score on hand for reference and estimating, etc, etc.  One problem – just how many notes are then in Mozart’s Requiem?

Well, when Google failed me, and I counted how many notes in one bar of the score (more than 40), I decided extrapolating from a sample of bars to the whole piece was impractical, I thought I’d look for help of a more technical kind.

Googling eventually found me a site with the complete Requiem as a series of MIDI files.  Great – thought I’d just load them into a sequencer and that would do the job.  But no, the sequencer’s I have and tried didn’t have a ‘total notes’ statistic anywhere that I could find.

Well, this is the point where the geek takes over … MIDI is just a series of instructions ‘turn this note on, turn this note off, change to violin here’ and so on.  So, armed with the MIDI files, I just have to find something that would count the ‘note on’ events in each track in each file.  Well, after a bit of playing around, and looking for help, I found the MIDI perl library.  This enabled the following script (stored here in case someone else has the same whimsical, insane idea and needs to do something similar).

#!/usr/bin/perl
use MIDI;

my $opus = MIDI::Opus->new({'from_file' => $ARGV[0]});
my $notes = 0;
my @tracks = $opus->tracks();
foreach my $track (@tracks)
{
   foreach my $event ($track->events())
   {
      if ($event->[0] eq 'note_on')
      {
         $notes++;
      }
   }
}
print "Note count: $notes\n";

And the number of notes? Ah, well that would be telling … lets just say that whoever said Mozart used ‘too many notes’ really just didn’t know what they were talking about …

Kevin.

4 thoughts on “How Many Notes in Mozart’s Requiem?

  1. I’ve not laugh out loud so hard for years. This level of geekiness to answer a simple question is the sign of a True Master – Sir, I doft my hat to you. Utterly brilliant stuff.

    (In a side note, first code you’ve cut in 2009?)

  2. Hehe … I’m afraid I have no idea anymore! I’ll see if I can find the files and run it again, but its been quite a while since I did this, but I’ll see … 🙂

    Kevin.

Leave a reply to emalliab Cancel reply