Merge remote-tracking branch 'origin/2.2.x' into master

This commit is contained in:
derselbst 2022-05-28 22:28:33 +02:00
commit f06619e079
2 changed files with 29 additions and 13 deletions

View file

@ -28,31 +28,47 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
fluid_settings_t *settings; fluid_settings_t *settings = NULL;
fluid_synth_t *synth; fluid_synth_t *synth = NULL;
fluid_audio_driver_t *adriver; fluid_audio_driver_t *adriver = NULL;
int sfont_id; int sfont_id;
int i, key; int i, key;
/* Create the settings. */ /* Create the settings. */
settings = new_fluid_settings(); settings = new_fluid_settings();
if(settings == NULL)
{
puts("Failed to create the settings!");
goto err;
}
/* Change the settings if necessary*/ /* Change the settings if necessary*/
/* Create the synthesizer. */ /* Create the synthesizer. */
synth = new_fluid_synth(settings); 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 /* Create the audio driver. The synthesizer starts playing as soon
as the driver is created. */ as the driver is created. */
adriver = new_fluid_audio_driver(settings, synth); adriver = new_fluid_audio_driver(settings, synth);
if(adriver == NULL)
/* 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)
{ {
puts("Loading the SoundFont failed!"); puts("Failed to create the audio driver!");
goto err; goto err;
} }
@ -61,7 +77,6 @@ int main(int argc, char **argv)
for(i = 0; i < 12; i++) for(i = 0; i < 12; i++)
{ {
/* Generate a random key */ /* Generate a random key */
key = 60 + (int)(12.0f * rand() / (float) RAND_MAX); key = 60 + (int)(12.0f * rand() / (float) RAND_MAX);

View file

@ -320,8 +320,9 @@ find_fluid_audio_driver(fluid_settings_t *settings)
* Otherwise the behaviour is undefined. * Otherwise the behaviour is undefined.
* *
* @note As soon as an audio driver is created, the \p synth starts rendering audio. * @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, * This means that all necessary initialization and sound-setup should have been
* thus of all object types in use (synth, midi player, sequencer, etc.) the audio * 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! * 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. * Also refer to the order of object creation in the code examples.
*/ */