NAME

MIDI::Drummer::Tiny::Grooves - Common drum grooves

VERSION

version 0.7020

SYNOPSIS

use MIDI::Drummer::Tiny ();
use MIDI::Drummer::Tiny::Grooves ();

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

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

# get a random groove from all known grooves
my $groove = $grooves->get_groove;

my $set = $grooves->all_grooves;

# get a random groove from a set
$groove = $grooves->get_groove(0, $set);
# get a numbered groove
$groove = $grooves->get_groove(42);
print "42. $groove->{cat}\n$groove->{name}";

my $density = $grooves->density($groove);

# searching
$set = $grooves->search({ cat => 'house' });
$set = $grooves->search({ name => 'deep' }, $set); # refine search
$set = $grooves->search({ cat => 'house', name => 'deep' }); # same

# funk and soul patterns have WAY too much crashing imho:
$set = $grooves->search({ cat => 'funk' });
$groove = $grooves->get_groove(0, $set); # random funk groove
$groove = $grooves->swap_pat($groove, 'crash', 'closed');

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

$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'] },
      ...
    },
},

The known groove categories are:

Afro-Cuban,
Basic Patterns,
Breaks,
Breaks - Kick,
Breaks - Snare,
Drum Rolls,
Drum and Bass,
Dub,
EDM,
Electro,
Funk and Soul,
Ghost Snares,
Hip-Hop,
House,
Hybrid Breaks With Alternate Endings,
Irregular Breaks,
Miami Bass,
Pop,
Reggaeton,
Rock,
Rolling Breaks,
Standard Breaks

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

share_file

$share_file = $grooves->share_file;

The path to the drum-pattern-bit-strings.txt file.

Default: The installed distribution directory/file.

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

$grooves->groove(\%patterns);

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

swap_pat

$pat = $grooves->swap_pat($pattern, 'crash', 'closed');

density

$density = $grooves->density($groove);

Return the total number of strikes. This is basically the number of 1s in the instrument pattern.

TO DO

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

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.