]> git.xonotic.org Git - xonotic/mediasource.git/blobdiff - sound/weapons/tuba_loopnote_maker.mid.pl
make this mess work with fluidsynth too :P
[xonotic/mediasource.git] / sound / weapons / tuba_loopnote_maker.mid.pl
diff --git a/sound/weapons/tuba_loopnote_maker.mid.pl b/sound/weapons/tuba_loopnote_maker.mid.pl
new file mode 100644 (file)
index 0000000..5f9a3f3
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use MIDI;
+use MIDI::Opus;
+
+my ($file, $delta, $program, $velocity, $transpose, @notes) = @ARGV;
+
+my $track = MIDI::Track->new();
+
+$track->new_event('set_tempo', 0, $delta * 1000000);
+$track->new_event('patch_change', 0, 0, $program - 1);
+for(@notes)
+{
+       $track->new_event('note_on', 96, 0, $transpose + $_, $velocity);
+       $track->new_event('note_off', 96, 0, $transpose + $_, $velocity);
+}
+
+my $opus = MIDI::Opus->new({
+               format => 0,
+               ticks => 96,
+               tracks => [ $track ],
+               });
+
+$opus->write_to_file($file);