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

use MIDI::Drummer::Tiny;

my $d = MIDI::Drummer::Tiny->new(
    file      => "$0.mid",
    signature => '4/4',
    bpm       => 120,
    volume    => 100,
    bars      => 16, # Actually it's like 87
);

$d->score->synch(
    \&cymbals,
    \&drums,
);

$d->write;

sub cymbals {
    for my $n (1 .. $d->bars) {
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
        $d->note($d->eighth, $d->ride1);
    }
}

sub drums {
    for my $n (1 .. $d->bars) {
        $d->note($d->quarter, $d->kick);
        $d->note($d->eighth, $d->snare);
        $d->note($d->eighth, $d->kick);
        $d->note($d->eighth, $d->kick);
        $d->note($d->sixteenth, $d->hi_tom);
        $d->note($d->sixteenth, $d->hi_tom);
        $d->rest($d->quarter);
    }
}

$d->write;
