libfluidsynth 2.2.7
Fast file renderer for non-realtime MIDI file rendering

Instead of creating an audio driver as described in section Loading and playing a MIDI file one may chose to use the file renderer, which is the fastest way to synthesize MIDI files.

fluid_settings_t* settings;
settings = new_fluid_settings();
// specify the file to store the audio to
// make sure you compiled fluidsynth with libsndfile to get a real wave file
// otherwise this file will only contain raw s16 stereo PCM
fluid_settings_setstr(settings, "audio.file.name", "/path/to/output.wav");
// use number of samples processed as timing source, rather than the system timer
fluid_settings_setstr(settings, "player.timing-source", "sample");
// since this is a non-realtime scenario, there is no need to pin the sample data
fluid_settings_setint(settings, "synth.lock-memory", 0);
synth = new_fluid_synth(settings);
// *** loading of a soundfont omitted ***
player = new_fluid_player(synth);
fluid_player_add(player, "/path/to/midifile.mid");
renderer = new_fluid_file_renderer (synth);
{
{
break;
}
}
// just for sure: stop the playback explicitly and wait until finished
struct _fluid_file_renderer_t fluid_file_renderer_t
Audio file renderer instance.
Definition: types.h:47
struct _fluid_hashtable_t fluid_settings_t
Configuration settings instance.
Definition: types.h:38
struct _fluid_synth_t fluid_synth_t
Synthesizer instance.
Definition: types.h:39
struct _fluid_player_t fluid_player_t
MIDI player instance.
Definition: types.h:48
void delete_fluid_file_renderer(fluid_file_renderer_t *dev)
Close file and destroy a file renderer object.
Definition: fluid_filerenderer.c:358
int fluid_file_renderer_process_block(fluid_file_renderer_t *dev)
Write period_size samples to file.
Definition: fluid_filerenderer.c:394
fluid_file_renderer_t * new_fluid_file_renderer(fluid_synth_t *synth)
Create a new file renderer and open the file.
Definition: fluid_filerenderer.c:194
int fluid_player_get_status(fluid_player_t *player)
Get MIDI player status.
Definition: fluid_midi.c:2256
int fluid_player_join(fluid_player_t *player)
Wait for a MIDI player until the playback has been stopped.
Definition: fluid_midi.c:2489
int fluid_player_play(fluid_player_t *player)
Activates play mode for a MIDI player if not already playing.
Definition: fluid_midi.c:2208
void delete_fluid_player(fluid_player_t *player)
Delete a MIDI player instance.
Definition: fluid_midi.c:1733
fluid_player_t * new_fluid_player(fluid_synth_t *synth)
Create a new MIDI player.
Definition: fluid_midi.c:1645
int fluid_player_stop(fluid_player_t *player)
Pauses the MIDI playback.
Definition: fluid_midi.c:2241
int fluid_player_add(fluid_player_t *player, const char *midifile)
Add a MIDI file to a player queue.
Definition: fluid_midi.c:1879
@ FLUID_PLAYER_PLAYING
Player is currently playing.
Definition: midi.h:248
#define FLUID_OK
Value that indicates success, used by most libfluidsynth functions.
Definition: misc.h:56
int fluid_settings_setstr(fluid_settings_t *settings, const char *name, const char *str)
Set a string value for a named setting.
Definition: fluid_settings.c:963
void delete_fluid_settings(fluid_settings_t *settings)
Delete the provided settings object.
Definition: fluid_settings.c:286
int fluid_settings_setint(fluid_settings_t *settings, const char *name, int val)
Set an integer value for a setting.
Definition: fluid_settings.c:1534
fluid_settings_t * new_fluid_settings(void)
Create a new settings object.
Definition: fluid_settings.c:262
fluid_synth_t * new_fluid_synth(fluid_settings_t *settings)
Create new FluidSynth instance.
Definition: fluid_synth.c:624
void delete_fluid_synth(fluid_synth_t *synth)
Delete a FluidSynth instance.
Definition: fluid_synth.c:1019

Various output files types are supported, if compiled with libsndfile. Those can be specified via the settings object as well. Refer to the settings_audio documentation for more audio.file.\* options.