2003-03-11 16:56:45 +00:00
|
|
|
/* FluidSynth - A Software Synthesizer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Peter Hanappe and others.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2017-07-12 15:45:23 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
2017-07-12 15:53:03 +00:00
|
|
|
* as published by the Free Software Foundation; either version 2.1 of
|
2003-03-11 16:56:45 +00:00
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2017-07-12 15:45:23 +00:00
|
|
|
* Lesser General Public License for more details.
|
2007-03-04 16:45:05 +00:00
|
|
|
*
|
2017-07-12 15:54:54 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2003-03-11 16:56:45 +00:00
|
|
|
* License along with this library; if not, write to the Free
|
2011-08-15 12:57:10 +00:00
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA
|
2003-03-11 16:56:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fluid_adriver.h"
|
|
|
|
#include "fluid_settings.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fluid_adriver_definition_t
|
|
|
|
*/
|
|
|
|
|
2007-03-04 16:45:05 +00:00
|
|
|
typedef struct _fluid_audriver_definition_t
|
2003-03-11 16:56:45 +00:00
|
|
|
{
|
2017-10-21 10:40:38 +00:00
|
|
|
const char* name;
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_audio_driver_t* (*new)(fluid_settings_t* settings, fluid_synth_t* synth);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* (*new2)(fluid_settings_t* settings,
|
|
|
|
fluid_audio_func_t func,
|
2003-03-11 16:56:45 +00:00
|
|
|
void* data);
|
|
|
|
int (*free)(fluid_audio_driver_t* driver);
|
|
|
|
void (*settings)(fluid_settings_t* settings);
|
|
|
|
} fluid_audriver_definition_t;
|
|
|
|
|
|
|
|
|
2008-12-23 10:15:01 +00:00
|
|
|
#if PULSE_SUPPORT
|
|
|
|
fluid_audio_driver_t* new_fluid_pulse_audio_driver(fluid_settings_t* settings,
|
|
|
|
fluid_synth_t* synth);
|
|
|
|
fluid_audio_driver_t* new_fluid_pulse_audio_driver2(fluid_settings_t* settings,
|
|
|
|
fluid_audio_func_t func, void* data);
|
|
|
|
int delete_fluid_pulse_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_pulse_audio_driver_settings(fluid_settings_t* settings);
|
|
|
|
#endif
|
2003-03-11 16:56:45 +00:00
|
|
|
|
|
|
|
#if ALSA_SUPPORT
|
2003-03-12 00:58:20 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_alsa_audio_driver(fluid_settings_t* settings,
|
|
|
|
fluid_synth_t* synth);
|
|
|
|
fluid_audio_driver_t* new_fluid_alsa_audio_driver2(fluid_settings_t* settings,
|
|
|
|
fluid_audio_func_t func, void* data);
|
|
|
|
int delete_fluid_alsa_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_alsa_audio_driver_settings(fluid_settings_t* settings);
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if OSS_SUPPORT
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_oss_audio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_oss_audio_driver2(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_audio_func_t func, void* data);
|
|
|
|
int delete_fluid_oss_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_oss_audio_driver_settings(fluid_settings_t* settings);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if COREAUDIO_SUPPORT
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_core_audio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_core_audio_driver2(fluid_settings_t* settings,
|
|
|
|
fluid_audio_func_t func,
|
2003-03-11 16:56:45 +00:00
|
|
|
void* data);
|
|
|
|
int delete_fluid_core_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_core_audio_driver_settings(fluid_settings_t* settings);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DSOUND_SUPPORT
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_dsound_audio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
|
|
|
int delete_fluid_dsound_audio_driver(fluid_audio_driver_t* p);
|
2004-03-19 11:52:56 +00:00
|
|
|
void fluid_dsound_audio_driver_settings(fluid_settings_t* settings);
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if PORTAUDIO_SUPPORT
|
2009-01-29 09:21:34 +00:00
|
|
|
void fluid_portaudio_driver_settings (fluid_settings_t *settings);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_portaudio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
|
|
|
int delete_fluid_portaudio_driver(fluid_audio_driver_t* p);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if JACK_SUPPORT
|
|
|
|
fluid_audio_driver_t* new_fluid_jack_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_jack_audio_driver2(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_audio_func_t func, void* data);
|
|
|
|
int delete_fluid_jack_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_jack_audio_driver_settings(fluid_settings_t* settings);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SNDMAN_SUPPORT
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_sndmgr_audio_driver2(fluid_settings_t* settings,
|
|
|
|
fluid_audio_func_t func,
|
2003-03-11 16:56:45 +00:00
|
|
|
void* data);
|
|
|
|
int delete_fluid_sndmgr_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
#endif
|
|
|
|
|
2009-02-04 07:45:44 +00:00
|
|
|
#if DART_SUPPORT
|
|
|
|
fluid_audio_driver_t* new_fluid_dart_audio_driver(fluid_settings_t* settings,
|
|
|
|
fluid_synth_t* synth);
|
|
|
|
int delete_fluid_dart_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
void fluid_dart_audio_driver_settings(fluid_settings_t* settings);
|
|
|
|
#endif
|
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if AUFILE_SUPPORT
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t* new_fluid_file_audio_driver(fluid_settings_t* settings,
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_synth_t* synth);
|
|
|
|
int delete_fluid_file_audio_driver(fluid_audio_driver_t* p);
|
|
|
|
#endif
|
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2008-12-23 10:15:01 +00:00
|
|
|
/* Available audio drivers, listed in order of preference */
|
|
|
|
#if JACK_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define JACK_DEF_INIT \
|
|
|
|
{ "jack", \
|
|
|
|
new_fluid_jack_audio_driver, \
|
|
|
|
new_fluid_jack_audio_driver2, \
|
|
|
|
delete_fluid_jack_audio_driver, \
|
|
|
|
fluid_jack_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define JACK_DEF_INIT
|
2008-12-23 10:15:01 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if ALSA_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define ALSA_DEF_INIT \
|
|
|
|
{ "alsa", \
|
|
|
|
new_fluid_alsa_audio_driver, \
|
|
|
|
new_fluid_alsa_audio_driver2, \
|
|
|
|
delete_fluid_alsa_audio_driver, \
|
|
|
|
fluid_alsa_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define ALSA_DEF_INIT
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2008-12-23 10:15:01 +00:00
|
|
|
#if OSS_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define OSS_DEF_INIT \
|
|
|
|
{ "oss", \
|
|
|
|
new_fluid_oss_audio_driver, \
|
|
|
|
new_fluid_oss_audio_driver2, \
|
|
|
|
delete_fluid_oss_audio_driver, \
|
|
|
|
fluid_oss_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define OSS_DEF_INIT
|
2008-12-23 10:15:01 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2009-03-16 01:37:21 +00:00
|
|
|
#if PULSE_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define PULSE_DEF_INIT \
|
|
|
|
{ "pulseaudio", \
|
|
|
|
new_fluid_pulse_audio_driver, \
|
|
|
|
new_fluid_pulse_audio_driver2, \
|
|
|
|
delete_fluid_pulse_audio_driver, \
|
|
|
|
fluid_pulse_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define PULSE_DEF_INIT
|
2009-03-16 01:37:21 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if COREAUDIO_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define COREAUDIO_DEF_INIT \
|
|
|
|
{ "coreaudio", \
|
|
|
|
new_fluid_core_audio_driver, \
|
|
|
|
new_fluid_core_audio_driver2, \
|
|
|
|
delete_fluid_core_audio_driver, \
|
|
|
|
fluid_core_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define COREAUDIO_DEF_INIT
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if DSOUND_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define DSOUND_DEF_INIT \
|
|
|
|
{ "dsound", \
|
|
|
|
new_fluid_dsound_audio_driver, \
|
|
|
|
NULL, \
|
|
|
|
delete_fluid_dsound_audio_driver, \
|
|
|
|
fluid_dsound_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define DSOUND_DEF_INIT
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if PORTAUDIO_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define PORTAUDIO_DEF_INIT \
|
|
|
|
{ "portaudio", \
|
|
|
|
new_fluid_portaudio_driver, \
|
|
|
|
NULL, \
|
|
|
|
delete_fluid_portaudio_driver, \
|
|
|
|
fluid_portaudio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define PORTAUDIO_DEF_INIT
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if SNDMAN_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define SNDMAN_DEF_INIT \
|
|
|
|
{ "sndman", \
|
|
|
|
new_fluid_sndmgr_audio_driver, \
|
|
|
|
new_fluid_sndmgr_audio_driver2, \
|
|
|
|
delete_fluid_sndmgr_audio_driver, \
|
|
|
|
NULL },
|
|
|
|
#else
|
|
|
|
#define SNDMAN_DEF_INIT
|
2003-03-11 16:56:45 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2009-02-04 07:45:44 +00:00
|
|
|
#if DART_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define DART_DEF_INIT \
|
|
|
|
{ "dart", \
|
|
|
|
new_fluid_dart_audio_driver, \
|
|
|
|
NULL, \
|
|
|
|
delete_fluid_dart_audio_driver, \
|
|
|
|
fluid_dart_audio_driver_settings },
|
|
|
|
#else
|
|
|
|
#define DART_DEF_INIT
|
2009-02-04 07:45:44 +00:00
|
|
|
#endif
|
2017-11-01 15:20:16 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
#if AUFILE_SUPPORT
|
2017-11-01 15:20:16 +00:00
|
|
|
#define AUFILE_DEF_INIT \
|
|
|
|
{ "file", \
|
|
|
|
new_fluid_file_audio_driver, \
|
|
|
|
NULL, \
|
|
|
|
delete_fluid_file_audio_driver, \
|
|
|
|
NULL },
|
|
|
|
#else
|
|
|
|
#define AUFILE_DEF_INIT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define AVAILABLE_AUDRIVERS \
|
|
|
|
JACK_DEF_INIT \
|
|
|
|
ALSA_DEF_INIT \
|
|
|
|
OSS_DEF_INIT \
|
|
|
|
PULSE_DEF_INIT \
|
|
|
|
COREAUDIO_DEF_INIT \
|
|
|
|
DSOUND_DEF_INIT \
|
|
|
|
PORTAUDIO_DEF_INIT \
|
|
|
|
SNDMAN_DEF_INIT \
|
|
|
|
DART_DEF_INIT \
|
|
|
|
AUFILE_DEF_INIT
|
|
|
|
|
|
|
|
/* fluid_audio_drivers_template is a compile-constant template containing all audio drivers
|
|
|
|
* fluidsynth has been built with
|
|
|
|
*
|
|
|
|
* fluid_audio_drivers contains all the drivers registered for usage with
|
|
|
|
* fluid_audio_driver_register()
|
|
|
|
*
|
|
|
|
* To maintain backwards compatibility, all available drivers are initially registered, so
|
|
|
|
* this must be the same as fluid_audio_drivers_template. But arrays are unassignable in C
|
|
|
|
* and copying them at runtime with memcpy in fluid_audio_driver_settings() wouldnt be
|
|
|
|
* threadsafe. So use this ugly macro hack to initialize both equally at compiletime.
|
|
|
|
*/
|
|
|
|
static const fluid_audriver_definition_t fluid_audio_drivers_template[] =
|
|
|
|
{
|
|
|
|
AVAILABLE_AUDRIVERS
|
2003-03-11 16:56:45 +00:00
|
|
|
};
|
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
static fluid_audriver_definition_t fluid_audio_drivers[] =
|
|
|
|
{
|
|
|
|
AVAILABLE_AUDRIVERS
|
|
|
|
};
|
2003-03-11 16:56:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
void fluid_audio_driver_settings(fluid_settings_t* settings)
|
|
|
|
{
|
2017-10-21 10:40:38 +00:00
|
|
|
unsigned int i;
|
2003-03-11 16:56:45 +00:00
|
|
|
|
|
|
|
fluid_settings_register_str(settings, "audio.sample-format", "16bits", 0, NULL, NULL);
|
|
|
|
fluid_settings_add_option(settings, "audio.sample-format", "16bits");
|
|
|
|
fluid_settings_add_option(settings, "audio.sample-format", "float");
|
|
|
|
|
|
|
|
#if defined(WIN32)
|
|
|
|
fluid_settings_register_int(settings, "audio.period-size", 512, 64, 8192, 0, NULL, NULL);
|
|
|
|
fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0, NULL, NULL);
|
|
|
|
#elif defined(MACOS9)
|
|
|
|
fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0, NULL, NULL);
|
|
|
|
fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0, NULL, NULL);
|
|
|
|
#else
|
|
|
|
fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0, NULL, NULL);
|
|
|
|
fluid_settings_register_int(settings, "audio.periods", 16, 2, 64, 0, NULL, NULL);
|
|
|
|
#endif
|
|
|
|
|
Added public API functions: fluid_synth_sysex, fluid_synth_activate_key_tuning, fluid_synth_activate_octave_tuning, fluid_synth_tune_notes, fluid_synth_activate_tuning and fluid_synth_deactivate_tuning.
Added audio.realtime, audio.realtime-prio, midi.realtime and midi.realtime-prio (only ALSA updated to use them at this point).
Fixed bug in new_fluid_channel() where tuning field was not initialized.
fluid_settings.h had wrong field order in prototypes for fluid_settings_register_num and fluid_settings_register_int.
Added multi core support: "synth.cpu-cores" setting, fluid_synth_core_thread_func() and many core_ variables to fluid_synth_t.
Switched fluid_mutex_t back to a normal non-recursive mutex and added fluid_rec_mutex_t.
Added fluid_cond_t thread synchronization stuff.
Added fluid_cond_mutex_t which is a dynamically allocated regular mutex for use with fluid_cond_t.
fluid_settings_t and fluid_synth_t are now using fluid_rec_mutex_t (same as before, just name change).
Added platform specific fluid_thread_self_set_prio() functions to fluid_sys.c for activating high priority for the calling thread.
Modified new_fluid_thread() to take a prio and prio_level parameters.
Added missing fluid_atomic_pointer_set().
fluid_voice_write() changed to only take a voice audio buffer to render to, mixing is done separately with new fluid_voice_mix().
fluid_voice_write() now returns the count of samples rendered.
fluid_voice_effects() split into fluid_voice_filter() and fluid_voice_mix().
Added dsp_buf_count field to fluid_voice_t to keep track of last count of samples rendered to dsp_buf.
fluid_voice_get_channel() converted to a macro.
Added FLUID_DEFAULT_AUDIO_RT_PRIO and FLUID_DEFAULT_MIDI_RT_PRIO in fluidsynth_priv.h, set to 90 and 80 respectively which get used for audio.realtime-prio and midi.realtime-prio (was 90 and 90 before).
2009-09-29 21:40:28 +00:00
|
|
|
fluid_settings_register_int (settings, "audio.realtime-prio",
|
2009-10-30 19:13:45 +00:00
|
|
|
FLUID_DEFAULT_AUDIO_RT_PRIO, 0, 99, 0, NULL, NULL);
|
Added public API functions: fluid_synth_sysex, fluid_synth_activate_key_tuning, fluid_synth_activate_octave_tuning, fluid_synth_tune_notes, fluid_synth_activate_tuning and fluid_synth_deactivate_tuning.
Added audio.realtime, audio.realtime-prio, midi.realtime and midi.realtime-prio (only ALSA updated to use them at this point).
Fixed bug in new_fluid_channel() where tuning field was not initialized.
fluid_settings.h had wrong field order in prototypes for fluid_settings_register_num and fluid_settings_register_int.
Added multi core support: "synth.cpu-cores" setting, fluid_synth_core_thread_func() and many core_ variables to fluid_synth_t.
Switched fluid_mutex_t back to a normal non-recursive mutex and added fluid_rec_mutex_t.
Added fluid_cond_t thread synchronization stuff.
Added fluid_cond_mutex_t which is a dynamically allocated regular mutex for use with fluid_cond_t.
fluid_settings_t and fluid_synth_t are now using fluid_rec_mutex_t (same as before, just name change).
Added platform specific fluid_thread_self_set_prio() functions to fluid_sys.c for activating high priority for the calling thread.
Modified new_fluid_thread() to take a prio and prio_level parameters.
Added missing fluid_atomic_pointer_set().
fluid_voice_write() changed to only take a voice audio buffer to render to, mixing is done separately with new fluid_voice_mix().
fluid_voice_write() now returns the count of samples rendered.
fluid_voice_effects() split into fluid_voice_filter() and fluid_voice_mix().
Added dsp_buf_count field to fluid_voice_t to keep track of last count of samples rendered to dsp_buf.
fluid_voice_get_channel() converted to a macro.
Added FLUID_DEFAULT_AUDIO_RT_PRIO and FLUID_DEFAULT_MIDI_RT_PRIO in fluidsynth_priv.h, set to 90 and 80 respectively which get used for audio.realtime-prio and midi.realtime-prio (was 90 and 90 before).
2009-09-29 21:40:28 +00:00
|
|
|
|
2003-03-11 16:56:45 +00:00
|
|
|
/* Set the default driver */
|
2009-03-16 01:37:21 +00:00
|
|
|
#if JACK_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "jack", 0, NULL, NULL);
|
2008-12-23 10:15:01 +00:00
|
|
|
#elif ALSA_SUPPORT
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_settings_register_str(settings, "audio.driver", "alsa", 0, NULL, NULL);
|
2009-03-16 01:37:21 +00:00
|
|
|
#elif PULSE_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "pulseaudio", 0, NULL, NULL);
|
2003-03-11 16:56:45 +00:00
|
|
|
#elif OSS_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "oss", 0, NULL, NULL);
|
|
|
|
#elif COREAUDIO_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "coreaudio", 0, NULL, NULL);
|
|
|
|
#elif DSOUND_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "dsound", 0, NULL, NULL);
|
|
|
|
#elif SNDMAN_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "sndman", 0, NULL, NULL);
|
|
|
|
#elif PORTAUDIO_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "portaudio", 0, NULL, NULL);
|
2009-02-04 07:45:44 +00:00
|
|
|
#elif DART_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "dart", 0, NULL, NULL);
|
2003-03-11 16:56:45 +00:00
|
|
|
#elif AUFILE_SUPPORT
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "file", 0, NULL, NULL);
|
|
|
|
#else
|
|
|
|
fluid_settings_register_str(settings, "audio.driver", "", 0, NULL, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Add all drivers to the list of options */
|
2008-12-23 10:15:01 +00:00
|
|
|
#if PULSE_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "pulseaudio");
|
|
|
|
#endif
|
2003-03-11 16:56:45 +00:00
|
|
|
#if ALSA_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "alsa");
|
|
|
|
#endif
|
|
|
|
#if OSS_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "oss");
|
|
|
|
#endif
|
|
|
|
#if COREAUDIO_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "coreaudio");
|
|
|
|
#endif
|
|
|
|
#if DSOUND_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "dsound");
|
|
|
|
#endif
|
|
|
|
#if SNDMAN_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "sndman");
|
|
|
|
#endif
|
|
|
|
#if PORTAUDIO_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "portaudio");
|
|
|
|
#endif
|
|
|
|
#if JACK_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "jack");
|
|
|
|
#endif
|
2009-02-04 07:45:44 +00:00
|
|
|
#if DART_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "dart");
|
|
|
|
#endif
|
2003-03-11 16:56:45 +00:00
|
|
|
#if AUFILE_SUPPORT
|
|
|
|
fluid_settings_add_option(settings, "audio.driver", "file");
|
|
|
|
#endif
|
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
for (i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers) && fluid_audio_drivers[i].name != NULL; i++) {
|
2003-03-11 16:56:45 +00:00
|
|
|
if (fluid_audio_drivers[i].settings != NULL) {
|
|
|
|
fluid_audio_drivers[i].settings(settings);
|
|
|
|
}
|
2006-12-10 16:02:04 +00:00
|
|
|
}
|
2003-03-11 16:56:45 +00:00
|
|
|
}
|
|
|
|
|
2006-12-10 16:02:04 +00:00
|
|
|
/**
|
|
|
|
* Create a new audio driver.
|
|
|
|
* @param settings Configuration settings used to select and create the audio
|
|
|
|
* driver.
|
|
|
|
* @param synth Synthesizer instance for which the audio driver is created for.
|
|
|
|
* @return The new audio driver instance.
|
|
|
|
*
|
|
|
|
* Creates a new audio driver for a given 'synth' instance with a defined set
|
|
|
|
* of configuration 'settings'.
|
|
|
|
*/
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t*
|
2003-03-11 16:56:45 +00:00
|
|
|
new_fluid_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|
|
|
{
|
2017-10-21 10:40:38 +00:00
|
|
|
unsigned int i;
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_audio_driver_t* driver = NULL;
|
|
|
|
char* name;
|
2009-10-23 02:18:26 +00:00
|
|
|
char *allnames;
|
2003-03-11 16:56:45 +00:00
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
for (i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers) && fluid_audio_drivers[i].name != NULL; i++) {
|
2003-03-11 16:56:45 +00:00
|
|
|
if (fluid_settings_str_equal(settings, "audio.driver", fluid_audio_drivers[i].name)) {
|
2006-02-19 10:01:58 +00:00
|
|
|
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver", fluid_audio_drivers[i].name);
|
2003-03-11 16:56:45 +00:00
|
|
|
driver = (*fluid_audio_drivers[i].new)(settings, synth);
|
|
|
|
if (driver) {
|
|
|
|
driver->name = fluid_audio_drivers[i].name;
|
2007-03-04 16:45:05 +00:00
|
|
|
}
|
2003-03-11 16:56:45 +00:00
|
|
|
return driver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-23 02:18:26 +00:00
|
|
|
allnames = fluid_settings_option_concat (settings, "audio.driver", NULL);
|
|
|
|
fluid_settings_dupstr (settings, "audio.driver", &name); /* ++ alloc name */
|
2009-09-22 07:04:07 +00:00
|
|
|
FLUID_LOG(FLUID_ERR, "Couldn't find the requested audio driver %s. Valid drivers are: %s.",
|
2009-10-23 02:18:26 +00:00
|
|
|
name ? name : "NULL", allnames ? allnames : "ERROR");
|
2009-09-22 07:04:07 +00:00
|
|
|
if (name) FLUID_FREE (name);
|
2009-10-23 02:18:26 +00:00
|
|
|
if (allnames) FLUID_FREE (allnames);
|
2003-03-11 16:56:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-12-10 16:02:04 +00:00
|
|
|
/**
|
|
|
|
* Create a new audio driver.
|
|
|
|
* @param settings Configuration settings used to select and create the audio
|
|
|
|
* driver.
|
|
|
|
* @param func Function called to fill audio buffers for audio playback
|
|
|
|
* @param data User defined data pointer to pass to 'func'
|
|
|
|
* @return The new audio driver instance.
|
|
|
|
*
|
|
|
|
* Like new_fluid_audio_driver() but allows for custom audio processing before
|
|
|
|
* audio is sent to audio driver. It is the responsibility of the callback
|
|
|
|
* 'func' to render the audio into the buffers.
|
2009-10-15 07:00:30 +00:00
|
|
|
*
|
2006-12-10 16:02:04 +00:00
|
|
|
* NOTE: Not as efficient as new_fluid_audio_driver().
|
|
|
|
*/
|
2007-03-04 16:45:05 +00:00
|
|
|
fluid_audio_driver_t*
|
2003-03-11 16:56:45 +00:00
|
|
|
new_fluid_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func, void* data)
|
|
|
|
{
|
2017-10-21 12:01:22 +00:00
|
|
|
unsigned int i;
|
2003-03-11 16:56:45 +00:00
|
|
|
fluid_audio_driver_t* driver = NULL;
|
|
|
|
char* name;
|
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
for (i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers) && fluid_audio_drivers[i].name != NULL; i++) {
|
2003-03-11 16:56:45 +00:00
|
|
|
if (fluid_settings_str_equal(settings, "audio.driver", fluid_audio_drivers[i].name) &&
|
|
|
|
(fluid_audio_drivers[i].new2 != NULL)) {
|
2006-02-19 10:01:58 +00:00
|
|
|
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver", fluid_audio_drivers[i].name);
|
2003-03-11 16:56:45 +00:00
|
|
|
driver = (*fluid_audio_drivers[i].new2)(settings, func, data);
|
|
|
|
if (driver) {
|
|
|
|
driver->name = fluid_audio_drivers[i].name;
|
2007-03-04 16:45:05 +00:00
|
|
|
}
|
2003-03-11 16:56:45 +00:00
|
|
|
return driver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 07:04:07 +00:00
|
|
|
fluid_settings_dupstr(settings, "audio.driver", &name); /* ++ alloc name */
|
|
|
|
FLUID_LOG(FLUID_ERR, "Couldn't find the requested audio driver: %s",
|
|
|
|
name ? name : "NULL");
|
|
|
|
if (name) FLUID_FREE (name);
|
2003-03-11 16:56:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-12-10 16:02:04 +00:00
|
|
|
/**
|
|
|
|
* Deletes an audio driver instance.
|
|
|
|
* @param driver Audio driver instance to delete
|
|
|
|
*
|
|
|
|
* Shuts down an audio driver and deletes its instance.
|
|
|
|
*/
|
2007-03-04 16:45:05 +00:00
|
|
|
void
|
2003-03-11 16:56:45 +00:00
|
|
|
delete_fluid_audio_driver(fluid_audio_driver_t* driver)
|
|
|
|
{
|
2017-10-21 12:01:22 +00:00
|
|
|
unsigned int i;
|
2003-03-11 16:56:45 +00:00
|
|
|
|
2017-10-30 16:42:37 +00:00
|
|
|
/* iterate over fluid_audio_drivers_template to ensure deleting even drivers currently not registered */
|
|
|
|
for (i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers_template); i++) {
|
|
|
|
if (fluid_audio_drivers_template[i].name == driver->name) {
|
|
|
|
fluid_audio_drivers_template[i].free(driver);
|
2003-03-11 16:56:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-30 16:42:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Registers audio drivers to use
|
|
|
|
*
|
|
|
|
* When creating a settings instance with new_fluid_settings(), all audio drivers are initialized once.
|
|
|
|
* In the past this has caused segfaults and application crashes due to buggy soundcard drivers.
|
|
|
|
*
|
|
|
|
* This function enables the user to only initialize specific audio drivers when settings instances are created.
|
|
|
|
* Therefore pass a NULL-terminated array of C-strings containing the \c names of audio drivers to register
|
|
|
|
* for the usage with fluidsynth.
|
2017-11-01 15:20:16 +00:00
|
|
|
* The \c names are the same as being used for the \c audio.driver setting.
|
2017-10-30 16:42:37 +00:00
|
|
|
*
|
|
|
|
* By default all audio drivers fluidsynth has been compiled with are registered.
|
|
|
|
*
|
|
|
|
* Any attempt of using audio drivers that have not been registered is undefined behaviour!
|
|
|
|
*
|
|
|
|
* @param adrivers NULL-terminated array of audio drivers to register. Pass NULL to register all available drivers.
|
|
|
|
* @return #FLUID_OK if all the audio drivers requested by the user are supported by fluidsynth and have been
|
|
|
|
* successfully registered. Otherwise #FLUID_FAILED is returned and ALL available audio drivers are registered instead.
|
|
|
|
*
|
|
|
|
* @warning This function may only be called if no thread is residing in fluidsynth's API and no instances
|
|
|
|
* of any kind are alive (e.g. as it would be the case right after fluidsynth's inital creation).
|
|
|
|
* Else the behaviour is undefined.
|
|
|
|
*
|
|
|
|
* @note This function is not thread safe and will never be!
|
|
|
|
*/
|
|
|
|
int fluid_audio_driver_register(const char** adrivers)
|
|
|
|
{
|
2017-11-01 15:20:16 +00:00
|
|
|
unsigned int i=0, add=0;
|
|
|
|
int res = FLUID_FAILED;
|
2017-10-30 16:42:37 +00:00
|
|
|
|
|
|
|
if(adrivers == NULL)
|
|
|
|
{
|
2017-11-01 15:20:16 +00:00
|
|
|
res = FLUID_OK;
|
|
|
|
goto cleanup;
|
2017-10-30 16:42:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FLUID_MEMSET(fluid_audio_drivers, 0, sizeof(fluid_audio_drivers));
|
|
|
|
for(i=0; adrivers[i] != NULL; i++)
|
|
|
|
{
|
2017-11-01 15:20:16 +00:00
|
|
|
unsigned int j;
|
2017-10-30 16:42:37 +00:00
|
|
|
/* search the requested audio driver in the template and copy it over if found */
|
|
|
|
for (j = 0; j < FLUID_N_ELEMENTS(fluid_audio_drivers_template); j++)
|
|
|
|
{
|
|
|
|
if (FLUID_STRCMP(adrivers[i], fluid_audio_drivers_template[j].name) == 0)
|
|
|
|
{
|
|
|
|
FLUID_MEMCPY(&fluid_audio_drivers[add], &fluid_audio_drivers_template[j], sizeof(fluid_audio_drivers[add]));
|
|
|
|
add++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(j >= FLUID_N_ELEMENTS(fluid_audio_drivers_template))
|
|
|
|
{
|
|
|
|
/* requested driver not found, failure */
|
2017-11-01 15:20:16 +00:00
|
|
|
goto cleanup;
|
2017-10-30 16:42:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i >= FLUID_N_ELEMENTS(fluid_audio_drivers_template))
|
|
|
|
{
|
|
|
|
/* user requested more drivers than this build of fluidsynth supports, failure */
|
2017-11-01 15:20:16 +00:00
|
|
|
goto cleanup;
|
2017-10-30 16:42:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
res = FLUID_OK;
|
|
|
|
return res;
|
2017-10-30 16:42:37 +00:00
|
|
|
|
2017-11-01 15:20:16 +00:00
|
|
|
cleanup:
|
|
|
|
FLUID_MEMCPY(fluid_audio_drivers, fluid_audio_drivers_template, sizeof(fluid_audio_drivers));
|
|
|
|
return res;
|
2017-10-30 16:42:37 +00:00
|
|
|
}
|