summaryrefslogtreecommitdiff
path: root/midicsv-1.1/drummer.pl
diff options
context:
space:
mode:
authorpepper <peppersclothescult@gmail.com>2015-01-19 00:02:46 -0800
committerpepper <peppersclothescult@gmail.com>2015-01-19 00:02:46 -0800
commit760d4d5a0fc89e5b14681879577a80e79795e4a3 (patch)
tree3698995f434a00a904f9fdff64a739eb21f53fdb /midicsv-1.1/drummer.pl
Diffstat (limited to 'midicsv-1.1/drummer.pl')
-rw-r--r--midicsv-1.1/drummer.pl59
1 files changed, 59 insertions, 0 deletions
diff --git a/midicsv-1.1/drummer.pl b/midicsv-1.1/drummer.pl
new file mode 100644
index 0000000..8299e8b
--- /dev/null
+++ b/midicsv-1.1/drummer.pl
@@ -0,0 +1,59 @@
+
+ require 'general_midi.pl';
+
+# Repeats, Note,
+# Duration, Velocity
+ @track = (4, $GM_Percussion{'Acoustic Bass Drum'},
+ 480, 127,
+ 4, $GM_Percussion{'Low-Mid Tom'},
+ 240, 127,
+ 1, 0, 120, 0,
+ 2, $GM_Percussion{'Hand Clap'},
+ 240, 127,
+ 1, 0, 240, 0
+ );
+
+ print << "EOD";
+0, 0, Header, 1, 1, 480
+1, 0, Start_track
+1, 0, Tempo, 500000
+EOD
+
+ $time = 0;
+
+ &loop(4, @track);
+
+ print << "EOD";
+1, $time, End_track
+0, 0, End_of_file
+EOD
+
+ sub note { # &note($note_number, $duration [, $velocity])
+ local ($which, $duration, $vel) = @_;
+
+ if ($which > 0) {
+ if (!defined($vel)) {
+ $vel = 127;
+ }
+ print("1, $time, Note_on_c, 9, $which, $vel\n");
+ }
+ $time += $duration;
+ if ($which > 0) {
+ print("1, $time, Note_off_c, 9, $which, 0\n");
+ }
+ }
+
+ sub loop { # &loop($ntimes, @track)
+ local ($loops, @tr) = @_;
+ local ($i, $r);
+
+ for ($i = 0; $i < $loops; $i++) {
+ local @t = @tr;
+ while ($#t > 0) {
+ local ($repeats, $note, $duration, $velocity) = splice(@t, 0, 4);
+ for ($r = 0; $r < $repeats; $r++) {
+ &note($note, $duration, $velocity);
+ }
+ }
+ }
+ }