MIDI::Drummer::Tiny - Glorified metronome
version 0.1805
use MIDI::Drummer::Tiny; my $d = MIDI::Drummer::Tiny->new( file => 'drums.mid', bpm => 100, volume => 100, signature => '5/4', bars => 8, reverb => 0, kit => 25, # TR-808 if using GM Level 2 #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->metronome44; # 4/4 time for the number of bars $d->flam($d->quarter, $d->snare); $d->crescendo_roll([50, 127, 1], $d->eighth, $d->thirtysecond); $d->note($d->sixteenth, $d->crash1); $d->accent_note(127, $d->sixteenth, $d->crash2); # Alternate kick and snare $d->note($d->quarter, $d->open_hh, $_ % 2 ? $d->kick : $d->snare) for 1 .. $d->beats * $d->bars; $d->write;
This module provides handy defaults and tools to produce a MIDI score with drum parts.
Default: MIDI-Drummer.mid
MIDI-Drummer.mid
Default: MIDI::Simple->new_score
MIDI::Simple->new_score
Default: 1 (Standard)
1
If you are going to play the MIDI file with a "General MIDI Level 2" soundfont, you can change kits.
8: Room 16: Power 24: Electronic 25: TR-808 26: ? 32: Jazz 40: Brush 48: Orchestra
Default: 63
63
Default: 9
9
Default: 100
100
Default: 120
120
Default: 4
4
Default: 4/4
4/4
beats / divisions
Computed given the signature.
Where the snare is by default the same as the acoustic_snare but can be overridden with the electric_snare ('n40').
'n40'
Where the kick is by default the same as the acoustic_bass but can be overridden with the electric_bass ('n36').
'n36'
$d = MIDI::Drummer::Tiny->new(%arguments);
Return a new MIDI::Drummer::Tiny object.
MIDI::Drummer::Tiny
$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.
$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.
$d->rest( $d->quarter );
Add a rest to the score.
$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.
$d->metronome34; $d->metronome34($bars);
Add a steady 3/4 beat to the score.
$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.
$d->metronome54; $d->metronome54($bars);
Add a 5/4 beat to the score.
$d->metronome58; $d->metronome58($bars);
Add a 5/8 beat to the score.
$d->metronome68; $d->metronome68($bars);
Add a 6/8 beat to the score.
$d->metronome74; $d->metronome74($bars);
Add a 7/4 beat to the score.
$d->metronome78; $d->metronome78($bars);
Add a 7/8 beat to the score.
$d->flam($spec); $d->flam( $spec, $patch );
Add a "flam" to the score, where a ghosted 64th gracenote is played before the primary note.
If not provided the snare is used for the patch.
$d->roll( $length, $spec ); $d->roll( $length, $spec, $patch );
Add a drum roll to the score, where the patch is played for duration length in spec increments.
$d->crescendo_roll( [$start, $end, $bezier], $length, $spec ); $d->crescendo_roll( [$start, $end, $bezier], $length, $spec, $patch );
Add a drum roll to the score, where the patch is played for duration length in spec notes, at increasing or decreasing volumes from start to end.
If true, the bezier flag will render the crescendo with a curve, rather than as a straight line.
| * | * vol | * | * |* --------------- time
$d->set_time_sig('5/4');
Set the signature, beats, divisions, and the score time_signature values based on the given string.
time_signature
$d->sync(@code_refs);
This is a simple pass-through to the score synch method.
synch
This allows simultaneous playing of multiple "tracks" defined by code references.
Output the score as a MIDI file with the module "file" attribute as the file name.
The metronome method sources in this module, the eg/* programs in this distribution, and also eg/drum-fills-advanced in the Music::Duration::Partition distribution
Math::Bezier
MIDI::Simple
Moo
Music::Duration
https://en.wikipedia.org/wiki/General_MIDI#Percussion
https://en.wikipedia.org/wiki/General_MIDI_Level_2#Drum_sounds
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2021 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.
To install MIDI::Drummer::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MIDI::Drummer::Tiny
CPAN shell
perl -MCPAN -e shell install MIDI::Drummer::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.