#!/usr/bin/env perl
use strict;
use warnings;

use Data::Dumper::Compact 'ddc';
use lib map { "$ENV{HOME}/sandbox/$_/lib" } qw(MIDI-Util);
use MIDI::Util;
use Music::Chord::Progression;

my $score = MIDI::Util::setup_score();

my $n = 12; # Number of chromatic scale notes

my $net = { map { $_ => [1 .. $n] } 1 .. $n };

my $chords = [ ('m') x $n ];

my $prog = Music::Chord::Progression->new(
  net        => $net,
  chords     => $chords,
  scale_name => 'chromatic',
  substitute => 1,
  tonic      => -1,
  resolve    => -1,
  verbose    => 1,
);
my $notes = $prog->generate;

for my $chord (@$notes) {
    my @chord = MIDI::Util::midi_format(@$chord);
    $score->n('wn', @chord);
}

$score->write_score("$0.mid");
