typedef struct audio_effect_interface audio_effect_interface_s;
typedef enum {
/* Acoustic Echo Cancellation */
- AUDIO_EFFECT_TYPE_AEC_SPEEX, /* aec from speexdsp */
- AUDIO_EFFECT_TYPE_AEC_WEBRTC, /* aec from webrtc-audio-processing */
- AUDIO_EFFECT_TYPE_AEC_REFCOPY, /* synthesis reference source into recording source */
+ AUDIO_EFFECT_METHOD_AEC_SPEEX, /* aec from speexdsp */
+ AUDIO_EFFECT_METHOD_AEC_WEBRTC, /* aec from webrtc-audio-processing */
+ AUDIO_EFFECT_METHOD_AEC_REFCOPY, /* synthesis reference source into recording source */
/* Noise Suppression */
- AUDIO_EFFECT_TYPE_NS_PSE, /* SAIC NS solution */
- AUDIO_EFFECT_TYPE_NS_RNNOISE, /* RNNoise */
+ AUDIO_EFFECT_METHOD_NS_PSE, /* SAIC NS solution */
+ AUDIO_EFFECT_METHOD_NS_RNNOISE, /* RNNoise */
/* Template */
- AUDIO_EFFECT_TYPE_AMPLIFY,
+ AUDIO_EFFECT_METHOD_AMPLIFY,
/* Experiment */
- AUDIO_EFFECT_TYPE_AGC_SPEEX,
- AUDIO_EFFECT_TYPE_MAX,
-} audio_effect_type_e;
+ AUDIO_EFFECT_METHOD_AGC_SPEEX,
+ AUDIO_EFFECT_METHOD_MAX,
+} audio_effect_method_e;
typedef enum {
AUDIO_EFFECT_FORMAT_S8,
size_t request_framesize;
} audio_effect_s;
-audio_effect_s *audio_effect_create(audio_effect_type_e type, int rate,
+audio_effect_s *audio_effect_create(audio_effect_method_e method, int rate,
int channels, audio_effect_format_e format,
size_t frames);
int audio_effect_process(audio_effect_s *ae, void *in, void *out);
typedef void (*dl_destroy_t)(void *);
typedef struct audio_effect_interface {
- audio_effect_type_e type;
+ audio_effect_method_e method;
dl_create_t create;
dl_process_t process;
dl_process_reference_t process_reference;
} constraint;
} audio_effect_plugin_info_s;
-audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
+audio_effect_interface_s *audio_effect_interface_new(audio_effect_method_e method,
int rate, int channels,
audio_effect_format_e format,
size_t frames);
Name: libaudio-effect
Summary: audio effect library
-Version: 0.0.1
+Version: 0.0.2
Release: 0
Group: System/Libraries
License: Apache-2.0
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
-audio_effect_s *audio_effect_create(audio_effect_type_e type, int rate, int channels,
+audio_effect_s *audio_effect_create(audio_effect_method_e method, int rate, int channels,
audio_effect_format_e format, size_t frames)
{
audio_effect_s *ae;
audio_effect_interface_s *intf;
- intf = audio_effect_interface_new(type, rate, channels, format, frames);
+ intf = audio_effect_interface_new(method, rate, channels, format, frames);
if (!intf) {
LOG_ERROR("failed to create interface");
return NULL;
#include <audio_effect_log.h>
static const char *effect_path_list[] = {
- [AUDIO_EFFECT_TYPE_AEC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-aec-speex.so",
- [AUDIO_EFFECT_TYPE_AEC_WEBRTC] = DL_PLUGIN_PATH "libaudio-effect-aec-webrtc.so",
- [AUDIO_EFFECT_TYPE_AEC_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-aec-refcopy.so",
- [AUDIO_EFFECT_TYPE_NS_PSE] = DL_PLUGIN_PATH "libaudio-effect-ns-pse.so",
- [AUDIO_EFFECT_TYPE_NS_RNNOISE] = DL_PLUGIN_PATH "libaudio-effect-ns-rnnoise.so",
- [AUDIO_EFFECT_TYPE_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
- [AUDIO_EFFECT_TYPE_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
+ [AUDIO_EFFECT_METHOD_AEC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-aec-speex.so",
+ [AUDIO_EFFECT_METHOD_AEC_WEBRTC] = DL_PLUGIN_PATH "libaudio-effect-aec-webrtc.so",
+ [AUDIO_EFFECT_METHOD_AEC_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-aec-refcopy.so",
+ [AUDIO_EFFECT_METHOD_NS_PSE] = DL_PLUGIN_PATH "libaudio-effect-ns-pse.so",
+ [AUDIO_EFFECT_METHOD_NS_RNNOISE] = DL_PLUGIN_PATH "libaudio-effect-ns-rnnoise.so",
+ [AUDIO_EFFECT_METHOD_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
+ [AUDIO_EFFECT_METHOD_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
};
static struct plugin_list {
void *handle;
int refcnt;
audio_effect_plugin_info_s *plugin_info;
-} plugin_list[AUDIO_EFFECT_TYPE_MAX];
+} plugin_list[AUDIO_EFFECT_METHOD_MAX];
-audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
+audio_effect_interface_s *audio_effect_interface_new(audio_effect_method_e method,
int rate, int channels,
audio_effect_format_e format,
size_t frames)
audio_effect_plugin_info_s *plugin_info;
void *handle = NULL;
- assert(type < AUDIO_EFFECT_TYPE_MAX);
+ assert(method < AUDIO_EFFECT_METHOD_MAX);
- if (!plugin_list[type].plugin_info && plugin_list[type].refcnt == 0) {
- handle = dlopen(effect_path_list[type], RTLD_LAZY);
+ if (!plugin_list[method].plugin_info && plugin_list[method].refcnt == 0) {
+ handle = dlopen(effect_path_list[method], RTLD_LAZY);
if (!handle) {
- LOG_INFO("Failed to open handle. path(%s)", effect_path_list[type]);
+ LOG_INFO("Failed to open handle. path(%s)", effect_path_list[method]);
return NULL;
}
- LOG_INFO("loaded module %s", effect_path_list[type]);
+ LOG_INFO("loaded module %s", effect_path_list[method]);
}
- plugin_info = plugin_list[type].plugin_info;
+ plugin_info = plugin_list[method].plugin_info;
assert(plugin_info);
/* check constraint */
if (plugin_info->constraint.frames != 0 && plugin_info->constraint.frames != frames)
LOG_WARN("This plugin uses fixed frames size. Check frames size with audio_effect_get_process_framesize api");
- plugin_list[type].handle = handle;
+ plugin_list[method].handle = handle;
/* TODO handle lock */
- plugin_list[type].refcnt += 1;
+ plugin_list[method].refcnt += 1;
return &plugin_info->interface;
{
assert(intf);
- plugin_list[intf->type].refcnt -= 1;
+ plugin_list[intf->method].refcnt -= 1;
- if (plugin_list[intf->type].refcnt == 0) {
- LOG_INFO("unloaded module %s", effect_path_list[intf->type]);
- dlclose(plugin_list[intf->type].handle);
+ if (plugin_list[intf->method].refcnt == 0) {
+ LOG_INFO("unloaded module %s", effect_path_list[intf->method]);
+ dlclose(plugin_list[intf->method].handle);
}
}
void audio_effect_register_module(audio_effect_plugin_info_s *plugin_info)
{
- audio_effect_type_e type;
+ audio_effect_method_e method;
assert(plugin_info);
/* TODO: Currently it's array */
- type = plugin_info->interface.type;
+ method = plugin_info->interface.method;
- plugin_list[type].plugin_info = plugin_info;
+ plugin_list[method].plugin_info = plugin_info;
}
void audio_effect_unregister_module(audio_effect_plugin_info_s *plugin_info)
{
- audio_effect_type_e type;
+ audio_effect_method_e method;
assert(plugin_info);
- type = plugin_info->interface.type;
+ method = plugin_info->interface.method;
- plugin_list[type].handle = NULL;
- plugin_list[type].refcnt = 0;
- plugin_list[type].plugin_info = NULL;
+ plugin_list[method].handle = NULL;
+ plugin_list[method].refcnt = 0;
+ plugin_list[method].plugin_info = NULL;
}
static audio_effect_plugin_info_s reference_copy = {
.name = "reference_copy",
.interface = {
- .type = AUDIO_EFFECT_TYPE_AEC_REFCOPY,
+ .method = AUDIO_EFFECT_METHOD_AEC_REFCOPY,
.create = reference_copy_create,
.process_reference = reference_copy_process_reference,
.destroy = reference_copy_destroy,
static audio_effect_plugin_info_s speex_aec = {
.name = "speex_aec",
.interface = {
- .type = AUDIO_EFFECT_TYPE_AEC_SPEEX,
+ .method = AUDIO_EFFECT_METHOD_AEC_SPEEX,
.create = speex_aec_create,
.process_reference = speex_aec_process_reference,
.destroy = speex_aec_destroy,
static audio_effect_plugin_info_s webrtc_aec = {
.name = "webrtc_aec",
.interface = {
- .type = AUDIO_EFFECT_TYPE_AEC_WEBRTC,
+ .method = AUDIO_EFFECT_METHOD_AEC_WEBRTC,
.create = webrtc_aec_create,
.process_reference = webrtc_aec_process_reference,
.destroy = webrtc_aec_destroy,
static audio_effect_plugin_info_s speex_agc = {
.name = "speex-agc",
.interface = {
- .type = AUDIO_EFFECT_TYPE_AGC_SPEEX,
+ .method = AUDIO_EFFECT_METHOD_AGC_SPEEX,
.create = speex_agc_create,
.process = speex_agc_process,
.destroy = speex_agc_destroy,
static audio_effect_plugin_info_s amplify = {
.name = "amplify",
.interface = {
- .type = AUDIO_EFFECT_TYPE_AMPLIFY,
+ .method = AUDIO_EFFECT_METHOD_AMPLIFY,
.create = amplify_create,
.process = amplify_process,
.destroy = amplify_destroy,
static audio_effect_plugin_info_s noise_suppression_rnnoise = {
.name = "noise-suppression-rnnoise",
.interface = {
- .type = AUDIO_EFFECT_TYPE_NS_RNNOISE,
+ .method = AUDIO_EFFECT_METHOD_NS_RNNOISE,
.create = noise_suppression_rnnoise_create,
.process = noise_suppression_rnnoise_process,
.destroy = noise_suppression_rnnoise_destroy,
exit(-1);
}
- ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+ ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize);
process_framesize = audio_effect_get_process_framesize(ae);
printf("process_framesize (%zu)\n", process_framesize);
exit(-1);
}
- ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_SPEEX, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+ ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_SPEEX, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
process_framesize = audio_effect_get_process_framesize(ae);
printf("process_framesize (%zu)\n", process_framesize);
exit(-1);
}
- ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+ ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
process_framesize = audio_effect_get_process_framesize(ae);
printf("process_framesize (%zu)\n", process_framesize);
exit(-1);
}
- ae = audio_effect_create(AUDIO_EFFECT_TYPE_AMPLIFY, 16000, 1, AUDIO_EFFECT_FORMAT_S16, FRAME_SIZE);
+ ae = audio_effect_create(AUDIO_EFFECT_METHOD_AMPLIFY, 16000, 1, AUDIO_EFFECT_FORMAT_S16, FRAME_SIZE);
while (!feof(fin)) {
printf("#%d frame. \n", i++);
ret = fread(in, FRAME_SIZE*sizeof(short), 1, fin);
exit(-1);
}
- ae = audio_effect_create(AUDIO_EFFECT_TYPE_NS_RNNOISE, 48000, 1, AUDIO_EFFECT_FORMAT_S16, framesize);
+ ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_RNNOISE, 48000, 1, AUDIO_EFFECT_FORMAT_S16, framesize);
assert(ae);
framesize = audio_effect_get_process_framesize(ae);