Re: Quintuplets again
[email protected] ("Sean M. Burke") Wed, 06 Aug 2003 21:13:44 -0800
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
OK, first off, I'm going quickly out of my mind calling two different aspects of the MIDI file "tempo". So I hereby decree that the number of ticks per quarter note is called the "denominatrix" (even tho you set it with "Tempo"). And the number of microseconds per quarter note is called the "pace" (even tho you set it with "set_tempo"). OK, now I can talk without going crazy. At 06:19 PM 2003-08-02 +0200, [email protected] wrote: >If I would want to use triplets, quintuplets, septuplets and >ninetuplets I would have to set it to 30240 right? Hm, my dictionary says that a nonuplet (a 9-tuplet) is "A group of nine notes to be performed in the time of eight or six.". Which sense do you mean? All this fraction math hurts my head. So I'll just answer your question about pace. >[...]lets say a phras with 5 quarter-quintuplets and three quarter-triplets... >This means I would have to set the tempo to 480 and the length of the >[...]now I want this to be played in Tempo 120... I think that the set_tempo (pace) command is irrespective of the current denominatrix setting. So I'm pretty sure that it's still this: set_tempo 500_000; # 1 qn => .5 seconds (500,000 microseconds) # = 120 bpm ...no matter what the current denominatrix is. >How would I have to write that code in an objectoriented way? >Would be great if someone could give me an example... use strict; use MIDI::Simple (); my $s = MIDI::Simple->new_score; $s->Tempo(480); # denominatrix! my @pitches = qw(n40 n43); $s->patch_change(0,1); $s->set_tempo( 500_000); # pace! # 1 qn => .5 seconds (500,000 microseconds) # i.e., a pace of 120bpm $s->noop( 'c0', 'qn' ); my $counter = 0; for(1 .. 120) { # so, 120 beats at 120bpm should be 1 minute! $s->n( $pitches[$counter++ % @pitches] ); } $s->write_score( "bipdeboop.mid" ); print "Done.\n"; (You can make an OO-less version of the above by just taking out all the "$s->" bits.) And I run drop the resulting file "bipdeboop.mid" onto Winamp or MSWin Media Player, and they both agree that it's 60 seconds long. If I had gotten the pace (set_tempo) wrong, it would have been a very different number. >By the was - is there actually a limit for the Tempo? Well, the denominatrix has to fix in 16 bits, and it's unsigned (and woe on any program that thinks it's signed), so I presume the limit is 2**16 - 1 = 65535. As to the pace, I think it has to fit in 3 bytes, so its maximum would be 2 ** 24 -1 = 16,777,215 microseconds per quarter note, or call that 17 seconds or about 4 b.p.m.. Going the other way, I presume the minimum value is 1 microsecond per quarternote, which gives you a peppy 60,000,000 b.p.m. But good luck finding sequencers that will tolerate anything like these extremes! Boy, I wanna hear what music you're writing now! -- Sean M. Burke http://search.cpan.org/~sburke/