The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl
use strict;
my $mdp = Music::Duration::Partition->new(
size => 8,
pool => [qw(hn qn ten)],
groups => [0, 0, 3],
verbose => 1,
);
my $motif = $mdp->motif;
warn(__PACKAGE__,' ',__LINE__," MARK: ",ddc($motif));
my @scale = get_scale_MIDI('C', 4, 'major');
my $score = MIDI::Simple->new_score;
for my $n (0 .. $#$motif * 8 - 1) {
$score->n($motif->[$n % @$motif], $scale[int rand @scale]);
}
$score->n('wn', $scale[0]);
$score->write_score("$0.mid");