File: chorus.pl

package info (click to toggle)
midicsv 1.1%2Bdfsg.1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch, trixie
  • size: 316 kB
  • ctags: 183
  • sloc: ansic: 1,304; perl: 471; makefile: 159
file content (28 lines) | stat: -rw-r--r-- 666 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

    #   Chorus all notes in a CSV MIDI file

    $offset = -12;
    $percussion = 9;

    while ($a = <>) {
        print($a);

        #   Recognise Note_on_c and Note_off_c records and crack into:

        #       $1  Start of record
        #       $2  Channel number
        #       $3  Note number
        #       $a  Balance of record

        if ($a =~ s/(\d+,\s*\d+,\s*Note_\w+,\s*(\d+),\s*)(\d+)//) {
            if ($2 != $percussion) {
                $n = $3;
                $n += $offset;
                if ($n < 0) {
                    next;
                }
                $a = "$1$n$a";
                print($a);
            }
        }
    }