mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-11 05:11:33 +00:00
55 lines
1.7 KiB
Text
55 lines
1.7 KiB
Text
/*!
|
|
|
|
\page MIDIPlayer Loading and playing a MIDI file
|
|
|
|
FluidSynth can be used to play MIDI files, using the MIDI File Player
|
|
interface. It follows a high level implementation, though its implementation
|
|
is currently incomplete. After initializing the synthesizer, create the
|
|
player passing the synth instance to new_fluid_player(). Then, you can add
|
|
some SMF file names to the player using fluid_player_add(), and finally call
|
|
fluid_player_play() to start the playback. You can check if the player has
|
|
finished by calling fluid_player_get_status(), or wait for the player to
|
|
terminate using fluid_player_join().
|
|
|
|
\code
|
|
#include <fluidsynth.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
int i;
|
|
fluid_settings_t* settings;
|
|
fluid_synth_t* synth;
|
|
fluid_player_t* player;
|
|
fluid_audio_driver_t* adriver;
|
|
settings = new_fluid_settings();
|
|
synth = new_fluid_synth(settings);
|
|
player = new_fluid_player(synth);
|
|
/* process command line arguments */
|
|
for (i = 1; i < argc; i++) {
|
|
if (fluid_is_soundfont(argv[i])) {
|
|
fluid_synth_sfload(synth, argv[1], 1);
|
|
}
|
|
if (fluid_is_midifile(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 */
|
|
fluid_player_play(player);
|
|
/* wait for playback termination */
|
|
fluid_player_join(player);
|
|
/* cleanup */
|
|
delete_fluid_audio_driver(adriver);
|
|
delete_fluid_player(player);
|
|
delete_fluid_synth(synth);
|
|
delete_fluid_settings(settings);
|
|
return 0;
|
|
}
|
|
\endcode
|
|
|
|
|
|
A list of available <strong>MIDI player settings</strong> can be found in the
|
|
\setting{player} documentation.
|
|
|
|
*/
|