NAME

MIDI::Drummer::Tiny::Grooves

VERSION

version 0.7014

SYNOPSIS

use MIDI::Drummer::Tiny ();
use MIDI::Drummer::Tiny::Grooves ();
# TODO use MIDI::Drummer::Tiny::Grooves qw(:house :rock); # maybe

my $drummer = MIDI::Drummer::Tiny->new(
  file => "grooves.mid",
  kick => 36,
);

my $grooves = MIDI::Drummer::Tiny::Grooves->new(
  drummer => $drummer
);

my $all = $grooves->all_grooves;

my $groove = $grooves->get_groove;  # random groove
$groove = $grooves->get_groove(42); # numbered groove
print "42. $groove->{cat}\n$groove->{name}";
$grooves->groove($groove->{groove}) for 1 .. 4; # add to score

my $set = $grooves->search({ cat => 'house' });
my $pattern = $set->{27}{groove}; # { kick => '...', }
$set = $grooves->search({ name => 'deep' }, $set); # refine search

for my $i (sort keys %$set) {
  $groove = $set->{$i};
  print "$i. $groove->{cat}\n$groove->{name}]\n";
  $grooves->groove($groove->{groove}); # a bit redundant!
}

$grooves->drummer->write;
# then:
# > timidity grooves.mid

DESCRIPTION

Return the common grooves, as listed in the "Pocket Operations", that are linked below. There are a total of 269 known drum patterns.

A groove is a numbered and named hash reference, with the following structure:

1 => {
    cat  => "Basic Patterns",
    name => "ONE AND SEVEN & FIVE AND THIRTEEN",
    groove => {
      kick  => { num => $self->kick,  pat => ['1000001000000000'] },
      snare => { num => $self->snare, pat => ['0000100000001000'] },
      ...
    },
},

ACCESSORS

drummer

$drummer = $grooves->drummer;
$grooves->drummer($drummer);

The MIDI::Drummer::Tiny object. If not given in the constructor, a new one is created when a method is called.

duration

$duration = $grooves->duration;
$grooves->duration($duration);

The "resolution" duration that is given to the "sync_patterns" in MIDI::Drummer::Tiny method.

This is initialized to the sixteenth duration of the drummer MIDI::Drummer::Tiny object.

kick, rimshot, snare, clap, conga, cowbell, shaker, closed, open, crash, hi_tom, mid_tom, low_tom

$kick = $grooves->kick;
$grooves->kick(36);

The drum patches that are used by the grooves.

Each is initialized to a corresponding patch of the drummer MIDI::Drummer::Tiny object that is given to, or created by the constructor.

return_patterns

$return_patterns = $grooves->return_patterns;

Either return the raw patterns of 16 beats or synch'ed drummer object phrases from the groove() method.

Default: 0

METHODS

new

$grooves = MIDI::Drummer::Tiny::Grooves->new;
$grooves = MIDI::Drummer::Tiny::Grooves->new(%arguments);

Return a new MIDI::Drummer::Tiny::Grooves object.

get_groove

$groove = $grooves->get_groove($groove_number);
$groove = $grooves->get_groove; # random groove
$groove = $grooves->get_groove(0, $set); # random groove of set
$groove = $grooves->get_groove($groove_number, $set); # numbered groove of set

Return a numbered or random groove from either the given set or all known grooves.

all_grooves

$all = $grooves->all_grooves;

Return all the known grooves as a hash reference.

$set = $grooves->search({ cat => $x, name => $y }); # search all grooves
$set = $grooves->search({ cat => $x, name => $y }, $set); # search a subset

Return the found grooves with names matching the cat or name strings and given an optional set of grooves to search in.

groove

$self->groove(\%patterns);

Add the patterns to the score. If the return_patterns attribute is on, the patterns are just returned.

SEE ALSO

The "Pocket Operations" at https://shittyrecording.studio/ (which contains a few typos and duplicates.)

AUTHOR

Gene Boggs <gene.boggs@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014-2026 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.