NAME
MIDI::Drummer::Tiny::Grooves
VERSION
version 0.7001
SYNOPSIS
use MIDI::Drummer::Tiny ();
use MIDI::Drummer::Tiny::Grooves ();
# TODO use MIDI::Drummer::Tiny::Grooves qw(:house :rock);
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
say $groove->{cat};
say $groove->{name};
$groove->{groove}->() for 1 .. 4; # add to score
my $set = $grooves->search({}, { cat => 'house' });
$set = $grooves->search($set, { name => 'deep' });
my @nums = keys %$set;
for (1 .. 4) {
$groove = $set->{ $nums[ rand @nums ] };
say $groove->{name};
$groove->{groove}->();
}
$grooves->drummer->write;
# then:
# > timidity grooves.mid
DESCRIPTION
Return the common grooves, as listed in the "Pocket Operations", that are linked below.
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 => sub {
$self->drummer->sync_patterns(
$self->kick => ['1000001000000000'],
$self->snare => ['0000100000001000'],
duration => $self->duration,
),
},
},
2 => { ... }, ... }
ACCESSORS
drummer
$grooves->drummer($drummer);
$drummer = $grooves->drummer;
The MIDI::Drummer::Tiny object. If not given in the constructor, a new one is created when a method is called.
duration
$grooves->duration($duration);
$duration = $grooves->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, cowbell, shaker, closed, open, cymbals, hi_tom, mid_tom, low_tom
$grooves->kick(36);
$kick = $grooves->kick;
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. (So changing these can be done in either the MIDI::Drummer::Tiny object, or in the Groove constructor.)
METHODS
new
$grooves = MIDI::Drummer::Tiny::Grooves->new;
$grooves = MIDI::Drummer::Tiny::Grooves->new(drummer => $drummer);
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.
search
$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.
SEE ALSO
The "Pocket Operations" at https://shittyrecording.studio/
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.