]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - sound/weapons/tuba_loopnote_maker.mid.pl
5f9a3f311421e033a2e7d60bc6303222d19a273f
[xonotic/mediasource.git] / sound / weapons / tuba_loopnote_maker.mid.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use MIDI;
6 use MIDI::Opus;
7
8 my ($file, $delta, $program, $velocity, $transpose, @notes) = @ARGV;
9
10 my $track = MIDI::Track->new();
11
12 $track->new_event('set_tempo', 0, $delta * 1000000);
13 $track->new_event('patch_change', 0, 0, $program - 1);
14 for(@notes)
15 {
16         $track->new_event('note_on', 96, 0, $transpose + $_, $velocity);
17         $track->new_event('note_off', 96, 0, $transpose + $_, $velocity);
18 }
19
20 my $opus = MIDI::Opus->new({
21                 format => 0,
22                 ticks => 96,
23                 tracks => [ $track ],
24                 });
25
26 $opus->write_to_file($file);