aboutsummaryrefslogtreecommitdiff
path: root/esp32/soundfont2-to-c-header
blob: 51b4ceac80a44cb68350966aca6da86985407d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env perl 
use strict;
use warnings;
 
open my $sf'<:raw'$ARGV[0]
    or die "give me a readable sf2 file\n";
 
open my $ch'>'$ARGV[1]
    or die "give me a writable h file\n";
 
my $data = do { local $/; <$sf> };
 
print $ch "const static unsigned char SoundFont[] PROGMEM = {\n";
 
for my $i ( 0 .. length($data) ) {
    my $v = substr($data,$i,1);
    printf $ch "0x%02x,",ord($v);
    if ($i%16 == 15) {
        print $ch "\n";
    }
}
 
print $ch "\n};\n";