mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-01 00:21:14 +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();
|
settings = new_fluid_settings();
|
||||||
synth = new_fluid_synth(settings);
|
synth = new_fluid_synth(settings);
|
||||||
player = new_fluid_player(synth);
|
player = new_fluid_player(synth);
|
||||||
adriver = new_fluid_audio_driver(settings, synth);
|
|
||||||
/* process command line arguments */
|
/* process command line arguments */
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (fluid_is_soundfont(argv[i])) {
|
if (fluid_is_soundfont(argv[i])) {
|
||||||
|
@ -386,6 +385,8 @@ int main(int argc, char** argv)
|
||||||
fluid_player_add(player, argv[i]);
|
fluid_player_add(player, argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* start the synthesizer thread */
|
||||||
|
adriver = new_fluid_audio_driver(settings, synth);
|
||||||
/* play the midi files, if any */
|
/* play the midi files, if any */
|
||||||
fluid_player_play(player);
|
fluid_player_play(player);
|
||||||
/* wait for playback termination */
|
/* wait for playback termination */
|
||||||
|
|
|
@ -119,19 +119,18 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* create the synth, driver and sequencer instances */
|
/* create the synth, driver and sequencer instances */
|
||||||
synth = new_fluid_synth(settings);
|
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 */
|
/* load a SoundFont */
|
||||||
n = fluid_synth_sfload(synth, argv[1], 1);
|
n = fluid_synth_sfload(synth, argv[1], 1);
|
||||||
|
|
||||||
if(n != -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)
|
if(argc > 2)
|
||||||
{
|
{
|
||||||
n = atoi(argv[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 */
|
/* get the current time in ticks */
|
||||||
time_marker = fluid_sequencer_get_tick(sequencer);
|
time_marker = fluid_sequencer_get_tick(sequencer);
|
||||||
/* schedule patterns */
|
/* schedule patterns */
|
||||||
|
@ -164,8 +165,8 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean and exit */
|
/* clean and exit */
|
||||||
delete_fluid_sequencer(sequencer);
|
|
||||||
delete_fluid_audio_driver(audiodriver);
|
delete_fluid_audio_driver(audiodriver);
|
||||||
|
delete_fluid_sequencer(sequencer);
|
||||||
delete_fluid_synth(synth);
|
delete_fluid_synth(synth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,19 +105,22 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* create the synth, driver and sequencer instances */
|
/* create the synth, driver and sequencer instances */
|
||||||
synth = new_fluid_synth(settings);
|
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 */
|
/* load a SoundFont */
|
||||||
n = fluid_synth_sfload(synth, argv[1], 1);
|
n = fluid_synth_sfload(synth, argv[1], 1);
|
||||||
|
|
||||||
if(n != -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)
|
if(argc > 2)
|
||||||
{
|
{
|
||||||
n = atoi(argv[2]);
|
n = atoi(argv[2]);
|
||||||
|
@ -150,8 +153,8 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean and exit */
|
/* clean and exit */
|
||||||
delete_fluid_sequencer(sequencer);
|
|
||||||
delete_fluid_audio_driver(audiodriver);
|
delete_fluid_audio_driver(audiodriver);
|
||||||
|
delete_fluid_sequencer(sequencer);
|
||||||
delete_fluid_synth(synth);
|
delete_fluid_synth(synth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue