mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-30 16:01:51 +00:00
Remove enum for output mode, use a simple flag instead
This commit is contained in:
parent
be38fa98e3
commit
1ba0450f3a
2 changed files with 22 additions and 30 deletions
|
@ -442,7 +442,7 @@ void fluid_ladspa_run(fluid_ladspa_fx_t *fx, int block_count, int block_size)
|
|||
{
|
||||
effect = fx->effects[i];
|
||||
|
||||
if (effect->mode == FLUID_LADSPA_MODE_ADD)
|
||||
if (effect->mix)
|
||||
{
|
||||
effect->desc->run_adding(effect->handle, num_samples);
|
||||
}
|
||||
|
@ -473,15 +473,15 @@ void fluid_ladspa_run(fluid_ladspa_fx_t *fx, int block_count, int block_size)
|
|||
|
||||
/**
|
||||
* Check if the effect plugin supports the run_adding and set_run_adding_gain
|
||||
* interfaces necessary for the FLUID_LADSPA_ADD output mode.
|
||||
* interfaces necessary for output mixing
|
||||
*
|
||||
* @param fx LADSPA fx
|
||||
* @param name the name of the effect
|
||||
* @return TRUE if add mode is supported, otherwise FALSE
|
||||
* @return TRUE if mix mode is supported, otherwise FALSE
|
||||
*/
|
||||
int fluid_ladspa_effect_can_add(fluid_ladspa_fx_t *fx, const char *name)
|
||||
int fluid_ladspa_effect_can_mix(fluid_ladspa_fx_t *fx, const char *name)
|
||||
{
|
||||
int can_add;
|
||||
int can_mix;
|
||||
fluid_ladspa_effect_t *effect;
|
||||
|
||||
LADSPA_API_ENTER(fx);
|
||||
|
@ -492,24 +492,23 @@ int fluid_ladspa_effect_can_add(fluid_ladspa_fx_t *fx, const char *name)
|
|||
LADSPA_API_RETURN(fx, FALSE);
|
||||
}
|
||||
|
||||
can_add = (effect->desc->run_adding != NULL
|
||||
can_mix = (effect->desc->run_adding != NULL
|
||||
&& effect->desc->set_run_adding_gain != NULL);
|
||||
|
||||
LADSPA_API_RETURN(fx, can_add);
|
||||
LADSPA_API_RETURN(fx, can_mix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the effect should replace everything in the output buffer(s) or add
|
||||
* to the buffer(s) with a fixed gain. The default mode is FLUID_LADSPA_MODE_REPLACE.
|
||||
* Set if the effect should replace everything in the output buffers (mix = 0, default)
|
||||
* or add to the buffers with a fixed gain (mix = 1).
|
||||
*
|
||||
* @param fx LADSPA fx instance
|
||||
* @param name the name of theeffect
|
||||
* @param mode which mode to set: FLUID_LADSPA_MODE_ADD or FLUID_LADSPA_MODE_REPLACE
|
||||
* @param gain the gain to apply to the effect output before adding to output. Ignored for replace mode.
|
||||
* @param name the name of the effect
|
||||
* @param mix (boolen) if to enable mix mode
|
||||
* @param gain the gain to apply to the effect output before adding to output.
|
||||
* @return FLUID_OK on success, otherwise FLUID_FAILED
|
||||
*/
|
||||
int fluid_ladspa_set_effect_mode(fluid_ladspa_fx_t *fx, const char *name,
|
||||
fluid_ladspa_mode_t mode, float gain)
|
||||
int fluid_ladspa_effect_set_mix(fluid_ladspa_fx_t *fx, const char *name, int mix, float gain)
|
||||
{
|
||||
fluid_ladspa_effect_t *effect;
|
||||
|
||||
|
@ -526,19 +525,18 @@ int fluid_ladspa_set_effect_mode(fluid_ladspa_fx_t *fx, const char *name,
|
|||
LADSPA_API_RETURN(fx, FLUID_FAILED);
|
||||
}
|
||||
|
||||
if (mode == FLUID_LADSPA_MODE_ADD)
|
||||
if (mix)
|
||||
{
|
||||
if (!fluid_ladspa_effect_can_add(fx, name))
|
||||
if (!fluid_ladspa_effect_can_mix(fx, name))
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Effect '%s' does not support 'add' mode",
|
||||
effect->desc->Label);
|
||||
FLUID_LOG(FLUID_ERR, "Effect '%s' does not support mix mode", name);
|
||||
LADSPA_API_RETURN(fx, FLUID_FAILED);
|
||||
}
|
||||
|
||||
effect->desc->set_run_adding_gain(effect->handle, gain);
|
||||
}
|
||||
|
||||
effect->mode = mode;
|
||||
effect->mix = mix;
|
||||
|
||||
LADSPA_API_RETURN(fx, FLUID_OK);
|
||||
}
|
||||
|
|
|
@ -57,12 +57,6 @@ typedef enum _fluid_ladspa_node_type_t {
|
|||
|
||||
} fluid_ladspa_node_type_t;
|
||||
|
||||
typedef enum _fluid_ladspa_mode_t {
|
||||
FLUID_LADSPA_MODE_REPLACE = 0,
|
||||
FLUID_LADSPA_MODE_ADD,
|
||||
|
||||
} fluid_ladspa_mode_t;
|
||||
|
||||
typedef struct _fluid_ladspa_lib_t
|
||||
{
|
||||
char *filename;
|
||||
|
@ -99,8 +93,9 @@ typedef struct _fluid_ladspa_effect_t
|
|||
|
||||
int active;
|
||||
|
||||
/* Decides if to replace data in output buffer (default) or add to it */
|
||||
fluid_ladspa_mode_t mode;
|
||||
/* Decides if we should call the run (mix = 0) or run_adding (mix = 1)
|
||||
* plugin interface */
|
||||
int mix;
|
||||
|
||||
/* Used to keep track of the port connection state */
|
||||
fluid_ladspa_node_t **port_nodes;
|
||||
|
@ -158,9 +153,8 @@ int fluid_ladspa_reset(fluid_ladspa_fx_t *fx);
|
|||
|
||||
int fluid_ladspa_add_effect(fluid_ladspa_fx_t *fx, const char *effect_name,
|
||||
const char *lib_name, const char *plugin_name);
|
||||
int fluid_ladspa_effect_can_add(fluid_ladspa_fx_t *fx, const char *name);
|
||||
int fluid_ladspa_set_effect_mode(fluid_ladspa_fx_t *fx, const char *name,
|
||||
fluid_ladspa_mode_t mode, float gain);
|
||||
int fluid_ladspa_effect_can_mix(fluid_ladspa_fx_t *fx, const char *name);
|
||||
int fluid_ladspa_effect_set_mix(fluid_ladspa_fx_t *fx, const char *name, int mix, float gain);
|
||||
int fluid_ladspa_effect_port_exists(fluid_ladspa_fx_t *fx, const char *effect_name, const char *port_name);
|
||||
int fluid_ladspa_host_port_exists(fluid_ladspa_fx_t *fx, const char *name);
|
||||
int fluid_ladspa_buffer_exists(fluid_ladspa_fx_t *fx, const char *name);
|
||||
|
|
Loading…
Reference in a new issue