💾 Archived View for thrig.me › blog › 2023 › 09 › 23 › markov2.pl captured on 2024-07-09 at 01:38:45.

View Raw

More Information

⬅️ Previous capture (2023-09-28)

-=-=-=-=-=-=-

#!/usr/bin/perl
use 5.36.0;
use MIDI::Simple;
use Music::VoiceGen;

my $voice = Music::VoiceGen->new(
    pitches   => [qw/60 62 64 65 67 69/],
    intervals => [qw/1 2 3 4 5 7 -1 -2 -3 -4 -5/],
);
my %rmap   = qw(0 hn 1 qn 2 en);
my $rhythm = Music::VoiceGen->new(
    possibles => {
        0 => { 0 => 0.25, 1 => 0.5, 2 => 1 },
        1 => { 0 => 0.25, 1 => 0.5, 2 => 0.5 },
        2 => { 0 => 1,    2 => 4 },
    }
);
for ( 1 .. 16 ) {
    my $n = $voice->rand;
    my $d = $rhythm->rand;
    n "d$rmap{$d}", $n;
}
print "\n";
write_score 'markov2.midi';