From cac2c6bf84571445b39e64b46729d857c27587ac Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 25 Aug 2019 10:59:11 +0200 Subject: [PATCH] Fix example code in the API docs order of object creation: audio driver must be last --- doc/fluidsynth-v20-devdoc.txt | 3 ++- doc/fluidsynth_arpeggio.c | 19 ++++++++++--------- doc/fluidsynth_metronome.c | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/fluidsynth-v20-devdoc.txt b/doc/fluidsynth-v20-devdoc.txt index ae8865f6..35f96d47 100644 --- a/doc/fluidsynth-v20-devdoc.txt +++ b/doc/fluidsynth-v20-devdoc.txt @@ -376,7 +376,6 @@ int main(int argc, char** argv) settings = new_fluid_settings(); synth = new_fluid_synth(settings); player = new_fluid_player(synth); - adriver = new_fluid_audio_driver(settings, synth); /* process command line arguments */ for (i = 1; i < argc; i++) { if (fluid_is_soundfont(argv[i])) { @@ -386,6 +385,8 @@ int main(int argc, char** argv) fluid_player_add(player, argv[i]); } } + /* start the synthesizer thread */ + adriver = new_fluid_audio_driver(settings, synth); /* play the midi files, if any */ fluid_player_play(player); /* wait for playback termination */ diff --git a/doc/fluidsynth_arpeggio.c b/doc/fluidsynth_arpeggio.c index 1955acc8..5d59a764 100644 --- a/doc/fluidsynth_arpeggio.c +++ b/doc/fluidsynth_arpeggio.c @@ -119,19 +119,18 @@ main(int argc, char *argv[]) { /* create the synth, driver and sequencer instances */ synth = new_fluid_synth(settings); - audiodriver = new_fluid_audio_driver(settings, synth); - sequencer = new_fluid_sequencer(); - /* register the synth with the sequencer */ - synth_destination = fluid_sequencer_register_fluidsynth(sequencer, - synth); - /* register the client name and callback */ - client_destination = fluid_sequencer_register_client(sequencer, - "arpeggio", sequencer_callback, NULL); /* load a SoundFont */ n = fluid_synth_sfload(synth, argv[1], 1); if(n != -1) { + sequencer = new_fluid_sequencer(); + /* register the synth with the sequencer */ + synth_destination = fluid_sequencer_register_fluidsynth(sequencer, + synth); + /* register the client name and callback */ + client_destination = fluid_sequencer_register_client(sequencer, + "arpeggio", sequencer_callback, NULL); if(argc > 2) { n = atoi(argv[2]); @@ -152,6 +151,8 @@ main(int argc, char *argv[]) } } + audiodriver = new_fluid_audio_driver(settings, synth); + /* get the current time in ticks */ time_marker = fluid_sequencer_get_tick(sequencer); /* schedule patterns */ @@ -164,8 +165,8 @@ main(int argc, char *argv[]) } /* clean and exit */ - delete_fluid_sequencer(sequencer); delete_fluid_audio_driver(audiodriver); + delete_fluid_sequencer(sequencer); delete_fluid_synth(synth); } diff --git a/doc/fluidsynth_metronome.c b/doc/fluidsynth_metronome.c index 72f508b4..248aca80 100644 --- a/doc/fluidsynth_metronome.c +++ b/doc/fluidsynth_metronome.c @@ -105,19 +105,22 @@ main(int argc, char *argv[]) { /* create the synth, driver and sequencer instances */ synth = new_fluid_synth(settings); - audiodriver = new_fluid_audio_driver(settings, synth); - sequencer = new_fluid_sequencer(); - /* register the synth with the sequencer */ - synth_destination = fluid_sequencer_register_fluidsynth(sequencer, - synth); - /* register the client name and callback */ - client_destination = fluid_sequencer_register_client(sequencer, - "fluidsynth_metronome", sequencer_callback, NULL); + /* load a SoundFont */ n = fluid_synth_sfload(synth, argv[1], 1); if(n != -1) { + sequencer = new_fluid_sequencer(); + /* register the synth with the sequencer */ + synth_destination = fluid_sequencer_register_fluidsynth(sequencer, + synth); + /* register the client name and callback */ + client_destination = fluid_sequencer_register_client(sequencer, + "fluidsynth_metronome", sequencer_callback, NULL); + + audiodriver = new_fluid_audio_driver(settings, synth); + if(argc > 2) { n = atoi(argv[2]); @@ -150,8 +153,8 @@ main(int argc, char *argv[]) } /* clean and exit */ - delete_fluid_sequencer(sequencer); delete_fluid_audio_driver(audiodriver); + delete_fluid_sequencer(sequencer); delete_fluid_synth(synth); }