aboutsummaryrefslogtreecommitdiff
path: root/esp32/soundfont2-to-c-header
diff options
context:
space:
mode:
Diffstat (limited to 'esp32/soundfont2-to-c-header')
-rw-r--r--esp32/soundfont2-to-c-header23
1 files changed, 23 insertions, 0 deletions
diff --git a/esp32/soundfont2-to-c-header b/esp32/soundfont2-to-c-header
new file mode 100644
index 0000000..51b4cea
--- /dev/null
+++ b/esp32/soundfont2-to-c-header
@@ -0,0 +1,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";