#ifndef WAP_AUDIO_PROCESSING_H
#define WAP_AUDIO_PROCESSING_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
enum WapDownmixMethod
#if defined(__cplusplus) || __STDC_VERSION__ >= 202311L
: int32_t
#endif {
AverageChannels = 0,
UseFirstChannel = 1,
};
#ifndef __cplusplus
#if __STDC_VERSION__ >= 202311L
typedef enum WapDownmixMethod WapDownmixMethod;
#else
typedef int32_t WapDownmixMethod;
#endif #endif
enum WapNoiseSuppressionLevel
#if defined(__cplusplus) || __STDC_VERSION__ >= 202311L
: int32_t
#endif {
Low = 0,
Moderate = 1,
High = 2,
VeryHigh = 3,
};
#ifndef __cplusplus
#if __STDC_VERSION__ >= 202311L
typedef enum WapNoiseSuppressionLevel WapNoiseSuppressionLevel;
#else
typedef int32_t WapNoiseSuppressionLevel;
#endif #endif
enum WapError
#if defined(__cplusplus) || __STDC_VERSION__ >= 202311L
: int32_t
#endif {
None = 0,
NullPointer = -1,
Internal = -2,
BadSampleRate = -3,
BadNumberChannels = -4,
BadStreamParameter = -5,
BadDataLength = -6,
};
#ifndef __cplusplus
#if __STDC_VERSION__ >= 202311L
typedef enum WapError WapError;
#else
typedef int32_t WapError;
#endif #endif
typedef struct WapAudioProcessing WapAudioProcessing;
typedef struct WapConfig {
int32_t pipeline_maximum_internal_processing_rate;
bool pipeline_multi_channel_render;
bool pipeline_multi_channel_capture;
WapDownmixMethod pipeline_capture_downmix_method;
bool pre_amplifier_enabled;
float pre_amplifier_fixed_gain_factor;
bool capture_level_adjustment_enabled;
float capture_level_adjustment_pre_gain_factor;
float capture_level_adjustment_post_gain_factor;
bool analog_mic_gain_emulation_enabled;
int32_t analog_mic_gain_emulation_initial_level;
bool high_pass_filter_enabled;
bool high_pass_filter_apply_in_full_band;
bool echo_canceller_enabled;
bool echo_canceller_enforce_high_pass_filtering;
bool noise_suppression_enabled;
WapNoiseSuppressionLevel noise_suppression_level;
bool noise_suppression_analyze_linear_aec_output_when_available;
bool gain_controller2_enabled;
float gain_controller2_fixed_digital_gain_db;
bool gain_controller2_adaptive_digital_enabled;
float gain_controller2_adaptive_digital_headroom_db;
float gain_controller2_adaptive_digital_max_gain_db;
float gain_controller2_adaptive_digital_initial_gain_db;
float gain_controller2_adaptive_digital_max_gain_change_db_per_second;
float gain_controller2_adaptive_digital_max_output_noise_level_dbfs;
bool gain_controller2_input_volume_controller_enabled;
} WapConfig;
typedef struct WapStreamConfig {
int32_t sample_rate_hz;
int32_t num_channels;
} WapStreamConfig;
typedef struct WapStats {
bool has_echo_return_loss;
double echo_return_loss;
bool has_echo_return_loss_enhancement;
double echo_return_loss_enhancement;
bool has_divergent_filter_fraction;
double divergent_filter_fraction;
bool has_delay_median_ms;
int32_t delay_median_ms;
bool has_delay_standard_deviation_ms;
int32_t delay_standard_deviation_ms;
bool has_residual_echo_likelihood;
double residual_echo_likelihood;
bool has_residual_echo_likelihood_recent_max;
double residual_echo_likelihood_recent_max;
bool has_delay_ms;
int32_t delay_ms;
} WapStats;
#ifdef __cplusplus
extern "C" {
#endif
const char *wap_version(void);
struct WapConfig wap_config_default(void);
struct WapAudioProcessing *wap_create(void);
struct WapAudioProcessing *wap_create_with_config(struct WapConfig config);
void wap_destroy(struct WapAudioProcessing *apm);
WapError wap_apply_config(struct WapAudioProcessing *apm, struct WapConfig config);
WapError wap_get_config(const struct WapAudioProcessing *apm, struct WapConfig *config_out);
WapError wap_initialize(struct WapAudioProcessing *apm,
struct WapStreamConfig input_config,
struct WapStreamConfig output_config,
struct WapStreamConfig reverse_input_config,
struct WapStreamConfig reverse_output_config);
WapError wap_process_stream_f32(struct WapAudioProcessing *apm,
const float *const *src,
struct WapStreamConfig input_config,
struct WapStreamConfig output_config,
float *const *dest);
WapError wap_process_reverse_stream_f32(struct WapAudioProcessing *apm,
const float *const *src,
struct WapStreamConfig input_config,
struct WapStreamConfig output_config,
float *const *dest);
WapError wap_process_stream_i16(struct WapAudioProcessing *apm,
const int16_t *src,
int32_t src_len,
struct WapStreamConfig input_config,
struct WapStreamConfig output_config,
int16_t *dest,
int32_t dest_len);
WapError wap_process_reverse_stream_i16(struct WapAudioProcessing *apm,
const int16_t *src,
int32_t src_len,
struct WapStreamConfig input_config,
struct WapStreamConfig output_config,
int16_t *dest,
int32_t dest_len);
WapError wap_set_stream_analog_level(struct WapAudioProcessing *apm, int32_t level);
int32_t wap_recommended_stream_analog_level(const struct WapAudioProcessing *apm);
WapError wap_set_stream_delay_ms(struct WapAudioProcessing *apm, int32_t delay);
int32_t wap_stream_delay_ms(const struct WapAudioProcessing *apm);
WapError wap_set_capture_pre_gain(struct WapAudioProcessing *apm, float gain);
WapError wap_set_capture_post_gain(struct WapAudioProcessing *apm, float gain);
WapError wap_set_capture_fixed_post_gain(struct WapAudioProcessing *apm, float gain_db);
WapError wap_set_playout_volume(struct WapAudioProcessing *apm, int32_t volume);
WapError wap_set_playout_audio_device(struct WapAudioProcessing *apm,
int32_t device_id,
int32_t max_volume);
WapError wap_set_capture_output_used(struct WapAudioProcessing *apm, bool used);
WapError wap_get_statistics(const struct WapAudioProcessing *apm, struct WapStats *stats_out);
#ifdef __cplusplus
} #endif
#endif