ref: ce0f88125032bfa5c1ddf78173e5e0a6e1e3bf75
parent: dea79b7c4e5daa857fd33b383ea3de34c77a670c
parent: 55532a7b210dc98e09fa1ea19dcc8ecd1addfc8e
author: Bernhard Schelling <14200249+schellingb@users.noreply.github.com>
date: Wed Sep 13 21:53:01 EDT 2023
Merge pull request #64 from ell1e/example3-with-args 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");