The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MIDI::Drummer::Tiny - Glorified metronome

VERSION

version 0.1400

SYNOPSIS

 use MIDI::Drummer::Tiny;

 my $d = MIDI::Drummer::Tiny->new(
    file      => 'drums.mid',
    bpm       => 100,
    signature => '5/4',
    bars      => 8,
    kick      => 'n36', # Override default patch
    snare     => 'n40', # "
 );

 $d->count_in(1);  # Closed hi-hat for 1 bar

 $d->metronome54;  # 5/4 time for the number of bars

 $d->set_time_sig('4/4');

 $d->rest($d->whole);

 $d->flam($d->quarter, $d->snare);
 $d->roll($d->eighth, $d->thirtysecond);

 $d->metronome44;  # 4/4 time for the number of bars

 # Alternate kick and snare
 $d->note($d->quarter, $d->open_hh, $_ % 2 ? $d->kick : $d->snare)
    for 1 .. $d->beats * $d->bars;

 $d->write;

DESCRIPTION

This module provides handy defaults and tools to produce a MIDI score with drum parts.

ATTRIBUTES

file

Default: MIDI-Drummer.mid

score

Default: MIDI::Simple->new_score

channel

Default: 9

volume

Default: 100

bpm

Default: 120

bars

Default: 4

signature

Default: 4/4

beats / divisions

beats

Computed given the signature.

divisions

Computed given the signature.

KIT

click, bell (metronome)
open_hh, closed_hh, pedal_hh
crash1, crash2, splash, china
ride1, ride2, ride_bell
side_stick, snare (alternate = n40), clap
hi_tom, hi_mid_tom, low_mid_tom, low_tom, hi_floor_tom, low_floor_tom
kick (alternate = n36)
tambourine, cowbell, vibraslap
hi_bongo, low_bongo, mute_hi_conga, open_hi_conga, low_conga, high_timbale, low_timbale
high_agogo, low_agogo, cabasa, maracas, short_whistle, long_whistle, short_guiro, long_guiro, claves, hi_wood_block, low_wood_block, mute_cuica, open_cuica
mute_triangle, open_triangle

DURATIONS

whole, triplet_whole, dotted_whole, double_dotted_whole
half, triplet_half, dotted_half, double_dotted_half
quarter, triplet_quarter, dotted_quarter, double_dotted_quarter
eighth, triplet_eighth, dotted_eighth, double_dotted_eighth
sixteenth, triplet_sixteenth, dotted_sixteenth, double_dotted_sixteenth
thirtysecond, triplet_thirtysecond, dotted_thirtysecond, double_dotted_thirtysecond
sixtyfourth, triplet_sixtyfourth, dotted_sixtyfourth, double_dotted_sixtyfourth
onetwentyeighth, triplet_onetwentyeighth, dotted_onetwentyeighth, double_dotted_onetwentyeighth

METHODS

new

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

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

note

 $d->note( $d->quarter, $d->closed_hh, $d->kick );
 $d->note( 'qn', 'n42', 'n35' ); # Same thing

Add a note to the score.

This method takes the same arguments as "Parameters for n/r/noop" in MIDI::Simple.

accent_note

  $d->accent_note($accent_value, $d->sixteenth, $d->snare);

Play an accented note.

For instance, this can be a "ghosted note", where the accent is a smaller number (< 50). Or a note that is greater than the normal score volume.

rest

 $d->rest( $d->quarter );

Add a rest to the score.

This method takes the same arguments as "Parameters for n/r/noop" in MIDI::Simple.

count_in

 $d->count_in;
 $d->count_in($bars);

Play the closed hihat for the number of beats times the given bars. If no bars are given, the default times the number of beats is used.

metronome34

  $d->metronome34;
  $d->metronome34($bars);

Add a steady 3/4 beat to the score.

metronome44

  $d->metronome44;
  $d->metronome44($bars);
  $d->metronome44($bars, $flag);
  $d->metronome44(16, 1);
  $d->metronome44(0, 1); # Use the ->bars attribute

Add a steady 4/4 beat to the score.

If a flag is provided the beat is modified to include alternating eighth-note kicks.

metronome54

  $d->metronome54;
  $d->metronome54($bars);

Add a 5/4 beat to the score.

metronome58

  $d->metronome58;
  $d->metronome58($bars);

Add a 5/8 beat to the score.

metronome68

  $d->metronome68;
  $d->metronome68($bars);

Add a 6/8 beat to the score.

metronome74

  $d->metronome74;
  $d->metronome74($bars);

Add a 7/4 beat to the score.

metronome78

  $d->metronome78;
  $d->metronome78($bars);

Add a 7/8 beat to the score.

flam

  $d->flam( $spec, $patch );

Add a flam to the score, where a ghosted gracenote is played before the primary note.

roll

  $d->roll( $length, $spec, $patch );

Add a drum roll to the score, where the patch is played for duration length in spec increments.

If not provided the snare is used for the patch.

set_time_sig

  $d->set_time_sig('5/4');

Set the signature, beats, divisions, and the score time_signature values based on the given string.

write

Output the score to the default *.mid file or one given to the constuctor.

SEE ALSO

The eg/* programs in this distribution and eg/drum-fills-advanced in the Music::Duration::Partition distribution

Moo

MIDI::Simple

Music::Duration

https://en.wikipedia.org/wiki/General_MIDI#Percussion

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 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.