MIDI::Simple::Drummer is a "robotic" drummer that provides simple methods to make beats.
This is not a "drum machine" that you control in a traditional, mechanical sense. It is intended to be a "sufficiently intelligent" drummer, with which you can practice, improvise, compose, record and experiment.
These "beats" are entirely constructed with perl and as such, any method can be used to generate the phrases - Stochastic, Evolutionary, L-system, Recursive descent grammar, Bayseian, Markov, Quantumm::Whatever...
Note that you, the programmer, should know what the patterns and kit elements are named and what they do. For these, check out the source of this package, the included style subclass(es), the eg/* files and the .mid files they produce.
The default kit is the exciting, general MIDI drumkit. Fortunately, you can import the .mid file into your favorite sequencer and assign better patches. Voilà !
SYNOPSIS
# A glorified metronome:
use MIDI::Simple::Drummer;
my $d = MIDI::Simple::Drummer->new(-bpm => 100);
$d->count_in;
for(1 .. $d->phrases * $d->bars) {
$d->note($d->EIGHTH, $d->backbeat_rhythm(-beat => $_));
$d->note($d->EIGHTH, $d->tick);
}
# Shuffle:
use MIDI::Simple::Drummer;
my $d = MIDI::Simple::Drummer->new(-bpm => 100);
$d->count_in;
for(1 .. $d->phrases * $d->bars) {
$d->note($d->TRIPLET_EIGHTH, $d->backbeat_rhythm(-beat => $_));
$d->rest($d->TRIPLET_EIGHTH);
$d->note($d->TRIPLET_EIGHTH, $d->tick);
}
# A rock drummer:
use MIDI::Simple::Drummer::Rock;
$d = MIDI::Simple::Drummer::Rock->new(-bpm => 100);
my($beat, $fill) = (0, 0);
$d->count_in;
for my $p (1 .. $d->phrases) {
if($p % 2 > 0) {
$beat = $d->beat(-name => 3, -fill => $fill);
}
else {
$beat = $d->beat(-name => 4);
$fill = $d->fill(-last => $fill);
}
}
$d->patterns(fin => \&fin);
$d->beat(-name => 'fin');
$d->write;
sub fin {
my $d = shift;
$d->note($d->EIGHTH, $d->option_strike;
$d->note($d->EIGHTH, $d->strike('Splash Cymbal','Bass Drum 1'));
$d->note($d->TRIPLET_SIXTEENTH, $d->snare) for 0 .. 2;
$d->rest($d->SIXTEENTH);
$d->note($d->EIGHTH, $d->strike('Splash Cymbal','Bass Drum 1'));
}
# Multi-tracking:
use MIDI::Simple::Drummer;
my $d = MIDI::Simple::Drummer->new;
$d->sync_tracks(
sub { $d->beat(-name => 'b1') },
sub { $d->beat(-name => 'b2') },
);
$d->write();
sub b1 { # tick
my $self = shift;
my %args = @_;
my $strike = $self->tick;
$self->note($self->QUARTER(), $strike) for 1 .. $self->beats;
return $strike;
}
sub b2 { # kick
my $self = shift;
my %args = @_;
my $strike = $self->kick;
$self->note($self->QUARTER(), $strike) for 1 .. $self->beats;
return $strike;
}
Product's homepage
Requirements:
· Perl