mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-27 22:43:36 +00:00
Fix example code in the API docs
order of object creation: audio driver must be last
This commit is contained in:
parent
f78486a50b
commit
cac2c6bf84
3 changed files with 24 additions and 19 deletions
|
@ -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 */
|
||||
|
|
|
@ -119,7 +119,11 @@ main(int argc, char *argv[])
|
|||
{
|
||||
/* create the synth, driver and sequencer instances */
|
||||
synth = new_fluid_synth(settings);
|
||||
audiodriver = new_fluid_audio_driver(settings, synth);
|
||||
/* 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,
|
||||
|
@ -127,11 +131,6 @@ main(int argc, char *argv[])
|
|||
/* 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,12 @@ main(int argc, char *argv[])
|
|||
{
|
||||
/* create the synth, driver and sequencer instances */
|
||||
synth = new_fluid_synth(settings);
|
||||
audiodriver = new_fluid_audio_driver(settings, synth);
|
||||
|
||||
/* 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,
|
||||
|
@ -113,11 +118,9 @@ main(int argc, char *argv[])
|
|||
/* 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue