Last active
October 22, 2017 23:10
-
-
Save mawe42/20a473ccdee83c364fcc126962656abb to your computer and use it in GitHub Desktop.
Idea for FluidSynth internal effects API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fluid_fx" | |
#include "fluid_freverb.h" | |
fluid_fx_handle_t *freeverb_instantiate(fluid_fx_descriptor_t *desc, fluid_real_t sample_rate) | |
{ | |
// create freeverb instance | |
} | |
void freeverb_cleanup(fluid_fx_handle_t *fx_handle) | |
{ | |
// cleanup freeverb instance | |
} | |
void freeverb_run(fluid_fx_handle_t *fx_handle, | |
fluid_real_t *left_in, fluid_real_t *right_in, | |
fluid_real_t *left_out, fluid_real_t *right_out, | |
int block_count, int block_size, int mix_output) | |
{ | |
// run freeverb | |
} | |
void freeverb_reset(fluid_fx_handle_t *fx_handle) | |
{ | |
// reset freverb | |
} | |
void freeverb_set_sample_rate(fluid_fx_handle_t *fx_handle, fluid_real_t sample_rate) | |
{ | |
// update sample rate | |
} | |
fluid_fx_descriptor_t fluid_reverb_fx_freeverb = { | |
.name = "freeverb", | |
.description = "The default reverb implementation of FluidSynth", | |
.type = FLUID_FX_REVERB, | |
.instantiate = freeverb_instantiate, | |
.cleanup = freeverb_cleanup, | |
.run = freeverb_run, | |
.reset = freeverb_reset, | |
.set_sample_rate = freeverb_set_sample_rate, | |
.set_param = fluid_fx_default_set_param, | |
.get_param = fluid_fx_default_get_param, | |
.has_param = fluid_fx_default_has_param, | |
.params = { | |
{ | |
.name = "roomsize", | |
.value = 0.0f, | |
}, | |
{ | |
.name = "damping", | |
.value = 0.0f, | |
}, | |
{ | |
.name = "width", | |
.value = 0.0f, | |
}, | |
{ | |
.name = "level", | |
.value = 0.0f, | |
} | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fluid_fx.h" | |
void fluid_fx_default_set_param(fluid_fx_handle_t *fx_handle, const char *name, fluid_real_t value) | |
{ | |
// default implementation to set a named parameter | |
} | |
fluid_real_t fluid_fx_default_get_param(fluid_fx_handle_t *fx_handle, const char *name) | |
{ | |
// default implementation to get a named parameter | |
} | |
int fluid_fx_default_has_param(fluid_fx_handle_t *fx_handle, const char *name) | |
{ | |
// default implementation to check if a named parameter exists | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum _fluid_fx_type_t | |
{ | |
FLUID_FX_REVERB = 0, | |
FLUID_FX_CHORUS | |
} fluid_fx_type_t; | |
typedef struct _fluid_fx_param_t | |
{ | |
const char *name; | |
fluid_real_t value; | |
const char *description; | |
} fluid_fx_param_t; | |
typedef _fluid_fx_handle_t | |
{ | |
/* Descriptor of the effect (see below) */ | |
fluid_fx_descriptor_t *descriptor; | |
/* Private data used for the effect */ | |
void *private; | |
} fluid_fx_handle_t; | |
typedef struct _fluid_fx_descriptor_t | |
{ | |
/* The name of the effect, used to select it from the command line via API */ | |
char *name; | |
/* Description of the effect */ | |
char *description; | |
/* The type of the effect, could also determine in which channel to write the output | |
*to keep the fixed reverb = 0, chorus = 1 mapping */ | |
fluid_fx_type_t type; | |
/* Creates a new instance of the effect */ | |
fluid_fx_handle_t *(*instantiate)(struct _fluid_fx_descriptor_t *desc, fluid_real_t sample_rate); | |
/* Delete an effect instance */ | |
void (*cleanup)(fluid_fx_handle_t *fx_handle); | |
/* Process one or more blocks of audio and either mix into or overwrite the output buffers */ | |
void (*run)(fluid_fx_handle_t *fx_handle, | |
fluid_real_t *left_in, fluid_real_t *right_in, | |
fluid_real_t *left_out, fluid_real_t *right_out, | |
int block_count, int block_size, | |
int mix_output); | |
/* Reset the effects, clearing all internal state and buffers */ | |
void (*reset)(fluid_fx_handle_t *fx_handle); | |
/* Update the sample rate */ | |
void (*set_sample_rate)(fluid_fx_handle_t *fx_handle, fluid_real_t sample_rate); | |
/* Set a named parameter */ | |
void (*set_param)(fluid_fx_handle_t *fx_handle, const char *name, fluid_real_t value); | |
/* Get the value of a named parameter */ | |
fluid_real_t (*get_param)(fluid_fx_handle_t *fx_handle, const char *name); | |
/* Check if the named parameter is available */ | |
int (*has_param)(fluid_fx_handle_t *fx_handle, const char *name); | |
/* Not part of the public API, should be accessed via *_param functions on the handle */ | |
fluid_fx_param_t params[]; | |
} fluid_fx_descriptor_t; | |
void fluid_fx_default_set_param(fluid_fx_handle_t *fx_handle, const char *name, fluid_real_t value); | |
fluid_real_t fluid_fx_default_get_param(fluid_fx_handle_t *fx_handle, const char *name); | |
int fluid_fx_default_has_param(fluid_fx_handle_t *fx_handle, const char *name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment