mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-11 05:11:33 +00:00
Merge pull request #242 from mawe42/ladspa-additional-fixes
More fixes to LADSPA system
This commit is contained in:
commit
799f3ea44c
3 changed files with 53 additions and 39 deletions
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
/* This module: 3/2002
|
/* This module: 3/2002
|
||||||
* Author: Markus Nentwig, nentwig@users.sourceforge.net
|
* Author: Markus Nentwig, nentwig@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* Complete rewrite: 10/2017
|
* Complete rewrite: 10/2017
|
||||||
* Author: Marcus Weseloh
|
* Author: Marcus Weseloh
|
||||||
*/
|
*/
|
||||||
|
@ -344,8 +344,10 @@ int fluid_ladspa_reset(fluid_ladspa_fx_t *fx)
|
||||||
* resulting audio back into the same buffers.
|
* resulting audio back into the same buffers.
|
||||||
*
|
*
|
||||||
* @param fx LADSPA effects instance
|
* @param fx LADSPA effects instance
|
||||||
* @param buf array of pointers into the interleaved left and right audio group buffers
|
* @param left_buf array of pointers into the left audio group buffers
|
||||||
* @param fx_buf array of pointers into the interleaved left and right effects channel buffers
|
* @param right_buf array of pointers into the right audio group buffers
|
||||||
|
* @param fx_left_buf array of pointers into the left effects buffers
|
||||||
|
* @param fx_right_buf array of pointers into the right effects buffers
|
||||||
*/
|
*/
|
||||||
void fluid_ladspa_run(fluid_ladspa_fx_t *fx, fluid_real_t *left_buf[], fluid_real_t *right_buf[],
|
void fluid_ladspa_run(fluid_ladspa_fx_t *fx, fluid_real_t *left_buf[], fluid_real_t *right_buf[],
|
||||||
fluid_real_t *fx_left_buf[], fluid_real_t *fx_right_buf[])
|
fluid_real_t *fx_left_buf[], fluid_real_t *fx_right_buf[])
|
||||||
|
@ -812,6 +814,11 @@ int fluid_ladspa_control_defaults(fluid_ladspa_fx_t *fx)
|
||||||
|
|
||||||
LADSPA_API_ENTER(fx);
|
LADSPA_API_ENTER(fx);
|
||||||
|
|
||||||
|
if (fluid_ladspa_is_active(fx))
|
||||||
|
{
|
||||||
|
LADSPA_API_RETURN(fx, FLUID_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < fx->num_plugins; i++)
|
for (i = 0; i < fx->num_plugins; i++)
|
||||||
{
|
{
|
||||||
if (connect_default_control_nodes(fx, fx->plugins[i]) != FLUID_OK)
|
if (connect_default_control_nodes(fx, fx->plugins[i]) != FLUID_OK)
|
||||||
|
@ -930,51 +937,58 @@ int fluid_ladspa_check(fluid_ladspa_fx_t *fx, char *err, int err_size)
|
||||||
LADSPA_API_RETURN(fx, FLUID_OK);
|
LADSPA_API_RETURN(fx, FLUID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_FLOAT
|
||||||
|
|
||||||
static FLUID_INLINE void buffer_to_node(fluid_real_t *buffer, fluid_ladspa_node_t *node)
|
static FLUID_INLINE void buffer_to_node(fluid_real_t *buffer, fluid_ladspa_node_t *node)
|
||||||
{
|
{
|
||||||
#ifndef WITH_FLOAT
|
|
||||||
int i;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If the node is not used by any plugin, then we don't need to fill it */
|
/* If the node is not used by any plugin, then we don't need to fill it */
|
||||||
if (node->num_outputs == 0)
|
if (node->num_outputs > 0)
|
||||||
{
|
{
|
||||||
return;
|
FLUID_MEMCPY(node->buf, buffer, FLUID_BUFSIZE * sizeof(float));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static FLUID_INLINE void node_to_buffer(fluid_ladspa_node_t *node, fluid_real_t *buffer)
|
||||||
|
{
|
||||||
|
/* If the node has no inputs, then we don't need to copy it to the node */
|
||||||
|
if (node->num_inputs > 0)
|
||||||
|
{
|
||||||
|
FLUID_MEMCPY(buffer, node->buf, FLUID_BUFSIZE * sizeof(float));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* WITH_FLOAT */
|
||||||
|
|
||||||
|
static FLUID_INLINE void buffer_to_node(fluid_real_t *buffer, fluid_ladspa_node_t *node)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* If the node is not used by any plugin, then we don't need to fill it */
|
||||||
|
if (node->num_outputs > 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < FLUID_BUFSIZE; i++)
|
||||||
|
{
|
||||||
|
node->buf[i] = (LADSPA_Data)buffer[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_FLOAT
|
|
||||||
FLUID_MEMCPY(node->buf, buffer, FLUID_BUFSIZE * sizeof(float));
|
|
||||||
#else
|
|
||||||
for (i = 0; i < FLUID_BUFSIZE; i++)
|
|
||||||
{
|
|
||||||
node->buf[i] = (LADSPA_Data)buffer[i];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLUID_INLINE void node_to_buffer(fluid_ladspa_node_t *node, fluid_real_t *buffer)
|
static FLUID_INLINE void node_to_buffer(fluid_ladspa_node_t *node, fluid_real_t *buffer)
|
||||||
{
|
{
|
||||||
#ifndef WITH_FLOAT
|
|
||||||
int i;
|
int i;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If the node has no inputs, then we don't need to copy it to the node */
|
/* If the node has no inputs, then we don't need to copy it to the node */
|
||||||
if (node->num_inputs == 0)
|
if (node->num_inputs > 0)
|
||||||
{
|
{
|
||||||
return;
|
for (i = 0; i < FLUID_BUFSIZE; i++)
|
||||||
|
{
|
||||||
|
buffer[i] = (fluid_real_t)node->buf[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_FLOAT
|
|
||||||
FLUID_MEMCPY(buffer, node->buf, FLUID_BUFSIZE * sizeof(float));
|
|
||||||
#else
|
|
||||||
for (i = 0; i < FLUID_BUFSIZE; i++)
|
|
||||||
{
|
|
||||||
buffer[i] = (fluid_real_t)node->buf[i];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* WITH_FLOAT */
|
||||||
|
|
||||||
static void activate_plugin(fluid_ladspa_plugin_t *plugin)
|
static void activate_plugin(fluid_ladspa_plugin_t *plugin)
|
||||||
{
|
{
|
||||||
if (!plugin->active)
|
if (!plugin->active)
|
||||||
|
@ -1087,7 +1101,7 @@ static const LADSPA_Descriptor *get_plugin_descriptor(const fluid_ladspa_lib_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a new LADSPA plugin from a library and set up the associated
|
* Instantiate a new LADSPA plugin from a library and set up the associated
|
||||||
* control structures needed by the LADSPA fx engine.
|
* control structures needed by the LADSPA fx engine.
|
||||||
*
|
*
|
||||||
|
@ -1144,7 +1158,7 @@ static void delete_fluid_ladspa_plugin(fluid_ladspa_plugin_t *plugin)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin->ports != NULL)
|
if (plugin->ports != NULL)
|
||||||
{
|
{
|
||||||
FLUID_FREE(plugin->ports);
|
FLUID_FREE(plugin->ports);
|
||||||
|
|
|
@ -91,8 +91,8 @@ typedef struct _fluid_ladspa_node_t
|
||||||
fluid_ladspa_node_type_t type;
|
fluid_ladspa_node_type_t type;
|
||||||
LADSPA_Data *buf;
|
LADSPA_Data *buf;
|
||||||
|
|
||||||
char num_inputs;
|
int num_inputs;
|
||||||
char num_outputs;
|
int num_outputs;
|
||||||
|
|
||||||
} fluid_ladspa_node_t;
|
} fluid_ladspa_node_t;
|
||||||
|
|
||||||
|
|
|
@ -554,9 +554,7 @@ new_fluid_synth(fluid_settings_t *settings)
|
||||||
fluid_sfloader_t* loader;
|
fluid_sfloader_t* loader;
|
||||||
double gain;
|
double gain;
|
||||||
int i, nbuf;
|
int i, nbuf;
|
||||||
#ifdef LADSPA
|
|
||||||
int with_ladspa = 0;
|
int with_ladspa = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* initialize all the conversion tables and other stuff */
|
/* initialize all the conversion tables and other stuff */
|
||||||
if (fluid_synth_initialized == 0)
|
if (fluid_synth_initialized == 0)
|
||||||
|
@ -708,10 +706,10 @@ new_fluid_synth(fluid_settings_t *settings)
|
||||||
fluid_synth_add_default_mod(synth, &default_pitch_bend_mod, FLUID_SYNTH_ADD);
|
fluid_synth_add_default_mod(synth, &default_pitch_bend_mod, FLUID_SYNTH_ADD);
|
||||||
|
|
||||||
|
|
||||||
#ifdef LADSPA
|
|
||||||
/* Create and initialize the Fx unit.*/
|
/* Create and initialize the Fx unit.*/
|
||||||
fluid_settings_getint(settings, "synth.ladspa.active", &with_ladspa);
|
fluid_settings_getint(settings, "synth.ladspa.active", &with_ladspa);
|
||||||
if (with_ladspa) {
|
if (with_ladspa) {
|
||||||
|
#ifdef LADSPA
|
||||||
synth->ladspa_fx = new_fluid_ladspa_fx(synth->sample_rate, synth->audio_groups,
|
synth->ladspa_fx = new_fluid_ladspa_fx(synth->sample_rate, synth->audio_groups,
|
||||||
synth->effects_channels, synth->audio_channels);
|
synth->effects_channels, synth->audio_channels);
|
||||||
if(synth->ladspa_fx == NULL) {
|
if(synth->ladspa_fx == NULL) {
|
||||||
|
@ -719,8 +717,10 @@ new_fluid_synth(fluid_settings_t *settings)
|
||||||
goto error_recovery;
|
goto error_recovery;
|
||||||
}
|
}
|
||||||
fluid_rvoice_mixer_set_ladspa(synth->eventhandler->mixer, synth->ladspa_fx);
|
fluid_rvoice_mixer_set_ladspa(synth->eventhandler->mixer, synth->ladspa_fx);
|
||||||
|
#else /* LADSPA */
|
||||||
|
FLUID_LOG(FLUID_WARN, "FluidSynth has not been compiled with LADSPA support");
|
||||||
|
#endif /* LADSPA */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* allocate and add the default sfont loader */
|
/* allocate and add the default sfont loader */
|
||||||
loader = new_fluid_defsfloader(settings);
|
loader = new_fluid_defsfloader(settings);
|
||||||
|
|
Loading…
Reference in a new issue