shithub: sf2mid

Download patch

ref: 55532a7b210dc98e09fa1ea19dcc8ecd1addfc8e
parent: bf574519e601202c3a9d27a74f345921277eed39
author: Ellie <el@horse64.org>
date: Sat Nov 6 19:07:53 EDT 2021

Expand example3.c to accept arbitrary midi and sf2 choice

--- a/examples/example3.c
+++ b/examples/example3.c
@@ -53,6 +53,11 @@
 
 int main(int argc, char *argv[])
 {
+	// This implements a small program that you can launch without
+	// parameters for a default file & soundfont, or with these arguments:
+	//
+	// ./example3-... <yourfile>.mid <yoursoundfont>.sf2
+
 	tml_message* TinyMidiLoader = NULL;
 
 	// Define the desired audio output format we request
@@ -73,7 +78,7 @@
 	//Venture (Original WIP) by Ximon
 	//https://musescore.com/user/2391686/scores/841451
 	//License: Creative Commons copyright waiver (CC0)
-	TinyMidiLoader = tml_load_filename("venture.mid");
+	TinyMidiLoader = tml_load_filename((argc >= 2 ? argv[1] : "venture.mid"));
 	if (!TinyMidiLoader)
 	{
 		fprintf(stderr, "Could not load MIDI file\n");
@@ -84,7 +89,9 @@
 	g_MidiMessage = TinyMidiLoader;
 
 	// Load the SoundFont from a file
-	g_TinySoundFont = tsf_load_filename("florestan-subset.sf2");
+	g_TinySoundFont = tsf_load_filename(
+		(argc >= 3 ? argv[2] : "florestan-subset.sf2")
+	);
 	if (!g_TinySoundFont)
 	{
 		fprintf(stderr, "Could not load SoundFont\n");