Re: Quintuplets again

[email protected] Sat, 02 Aug 2003 20:10:15 +0200 (CEST)
Newsgroups perl.midi
Message-ID <[email protected]>
Hey,

I got it.... it works fine, thx to Noel Lairsons mail a few weeks
ago...
Anyway here would be some sample Code to play 9 over 7.
One thing I still wonder: What would then be the maximum of ticks per
beat?
Not that I want to fine the most precise way of playing 20 against
21.........
Here's my code:

#!/usr/bin/perl
## Time-stamp: "2000-12-02 12:28:59 MST" ##
use lib 'htdocs/ultimate/cgi-bin/Modules/Midi';
use MIDI::Simple;
use CGI qw/:standard/;
use POSIX;

new_score;
Tempo(480);
set_tempo int(60_000_000 / 60); # 60bpm

my $number_of_notes = 9;
my $number_of_tics = 3360;
my $bar_length = $number_of_tics/480;

#this would be 9 notes over 3360 tics  (7 beats)
my $note_duration = $number_of_tics/$number_of_notes;
#so create an array of note values
for(my $a = 0; $a<$number_of_notes; $a++) {
    $notes[$a] = ceil($note_duration);
}

$remainder = $number_of_tics % $number_of_notes;
print "---".$remainder;
while($remainder > 0) {
    $notes[int(rand($#notes)+1)]++;
    $remainder--;
    print
}
#this randomly spreads extra tics around the array until all the values
in

@subs = (\&phrase, \&metronome);
foreach (1 .. 20) { synch(@subs) }



sub phrase
{
	my $it = shift;	
	my $count = 1;
	foreach (@notes) {
		my $duration = "d".$_;
		$it->n(c1,'v127',n40,$duration);		 	
	}
}

sub metronome
{
	my $it = shift;	
		foreach ($i=1; $i<=$bar_length;$i++) { 
			if ($i%$bar_length eq 1)
			{
				$it->n(c9,ff,n56,d480); 
			}
			else
			{
				$it->n(c9,f,n60,d480); 
			}
		}	
}

write_score 'test.mid';

exit;
###

Best regards,

Nikolai

[email protected] wrote:
> Hey everybody,
> 
> Somehow I have problems to send mails to the list...
> seems that there
> is a new program installed - so sorry if you get this
> mail twice!
> 
> I am little bit stuck with MIDI-Perl at the Moment....
> just read the new documentation and now I wanted to write
> 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
> Quintuplets to: 192 each
> and the triplets to: 320 each
> now I want this to be played in Tempo 120...
> How would I have to write that code in an objectoriented
> way?
> Would be great if someone could give me an example...
> 
> By the was - is there actually a limit for the Tempo?
> If I would want to use triplets, quintuplets, septuplets
> and
> ninetuplets I would have to set it to 30240 right?
> Thanks a lot for your support!
> Best regards,
> 
> Nikolai
>