My Robot Drummer...

DIY Beats

MIDI::Simple::Drummer

  1. It's on CPAN and will install on any machine.

  2. It only depends on MIDI::Simple, which depends on nothing but Perl itself!

Static not dynamic

Why make a MIDI drummer?

What Song Do You Think This Is?

Back In Black!

The General MIDI Kit

The GMK is pretty feeble but works just fine and is part of every machine.

Open the .mid in your favorite sequencer

And fiddle about. Every sequencer has better patches than the GMK.

The GMK is not Neil Peart's kit!

Let's Get This Party Started!

The Kit

Patterns and grooves, fills and frilly bits

Example rock pattern and fill

5 => sub { # "Syncopated beat 2" en c-hh. qn k1,3,3&,4&. qn s2,4.
 my $self = shift;
 my %args = @_;
 for my $beat (1 .. $self->beats) {
  $self->note($self->EIGHTH,
    $self->backbeat_rhythm(%args, -beat => $beat));
  $self->note($self->EIGHTH,
    ($beat == 3 || $beat == 4
      ? ($self->kick, $self->tick) : $self->tick));
 }
},
'1 fill' => sub {
 my $self = shift;
 $self->note($self->QUARTER, $self->snare) for 0 .. 1;
 $self->note($self->EIGHTH, $self->snare)  for 0 .. 3;
}, 

Some Dynamics

#
sub accent { # Pump up the [dynamics] (default Volume)!
 my $self = shift;
 $self->{-accent} = shift if @_;
 my $accent = $self->{-accent} + $self->volume;
 $accent = $MIDI::Simple::Volume{fff} # Max MIDI is fff
   if $accent > $MIDI::Simple::Volume{fff};
 return $accent;
} 

The Ugly Setup

#
sub _setup { # Where's my Roadies, Man?
 my $self = shift;
 $self->{-score} ||= MIDI::Simple->new_score;
 $self->{-score}->noop('c'.$self->{-channel}, 'V'.$self->{-volume});
 $self->{-score}->set_tempo(int(60_000_000 / $self->{-bpm}));
 $self->{-kit} ||= $self->_default_kit();
 $self->{-patterns} ||= $self->_default_patterns();
 return $self;
} 

The Lovely, Flexible Syntax

#
use MIDI::Simple::Drummer::Rock;
my $d = MIDI::Simple::Drummer::Rock->new();
$d->count_in;
$d->patterns('end fill' => \&fin);
$d->fill(-name => 'end');
$d->write;
sub fin {
 my $d = shift;
 $d->note('en', $d->crash) for 1 .. 2;
 $d->note('sn', $d->snare) for 0 .. 2;
 $d->rest('sn');
 $d->note('en', $d->kick) for 1 .. 2;
 $d->note('en', $d->strike('Splash Cymbal', $d->name_of('kick')));
} 

Any sufficiently advanced drummer...

The Future[TM]

To do

See also