mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Merge remote-tracking branch 'origin/2.2.x' into master
This commit is contained in:
commit
f06619e079
2 changed files with 29 additions and 13 deletions
|
@ -28,31 +28,47 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fluid_settings_t *settings;
|
||||
fluid_synth_t *synth;
|
||||
fluid_audio_driver_t *adriver;
|
||||
fluid_settings_t *settings = NULL;
|
||||
fluid_synth_t *synth = NULL;
|
||||
fluid_audio_driver_t *adriver = NULL;
|
||||
int sfont_id;
|
||||
int i, key;
|
||||
|
||||
/* Create the settings. */
|
||||
settings = new_fluid_settings();
|
||||
if(settings == NULL)
|
||||
{
|
||||
puts("Failed to create the settings!");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Change the settings if necessary*/
|
||||
|
||||
/* Create the synthesizer. */
|
||||
synth = new_fluid_synth(settings);
|
||||
if(synth == NULL)
|
||||
{
|
||||
puts("Failed to create the synth!");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Load a SoundFont and reset presets (so that new instruments
|
||||
* get used from the SoundFont)
|
||||
* Depending on the size of the SoundFont, this will take some time to complete...
|
||||
*/
|
||||
sfont_id = fluid_synth_sfload(synth, "example.sf2", 1);
|
||||
if(sfont_id == FLUID_FAILED)
|
||||
{
|
||||
puts("Loading the SoundFont failed!");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Create the audio driver. The synthesizer starts playing as soon
|
||||
as the driver is created. */
|
||||
adriver = new_fluid_audio_driver(settings, synth);
|
||||
|
||||
/* Load a SoundFont and reset presets (so that new instruments
|
||||
* get used from the SoundFont) */
|
||||
sfont_id = fluid_synth_sfload(synth, "example.sf2", 1);
|
||||
|
||||
if(sfont_id == FLUID_FAILED)
|
||||
if(adriver == NULL)
|
||||
{
|
||||
puts("Loading the SoundFont failed!");
|
||||
puts("Failed to create the audio driver!");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -61,7 +77,6 @@ int main(int argc, char **argv)
|
|||
|
||||
for(i = 0; i < 12; i++)
|
||||
{
|
||||
|
||||
/* Generate a random key */
|
||||
key = 60 + (int)(12.0f * rand() / (float) RAND_MAX);
|
||||
|
||||
|
|
|
@ -320,8 +320,9 @@ find_fluid_audio_driver(fluid_settings_t *settings)
|
|||
* Otherwise the behaviour is undefined.
|
||||
*
|
||||
* @note As soon as an audio driver is created, the \p synth starts rendering audio.
|
||||
* This means that all necessary sound-setup should be completed after this point,
|
||||
* thus of all object types in use (synth, midi player, sequencer, etc.) the audio
|
||||
* This means that all necessary initialization and sound-setup should have been
|
||||
* completed before calling this function.
|
||||
* Thus, of all object types in use (synth, midi player, sequencer, etc.) the audio
|
||||
* driver should always be the last one to be created and the first one to be deleted!
|
||||
* Also refer to the order of object creation in the code examples.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue