FreeSWITCH API Documentation
1.7.0
|
Audio Resample Code. More...
#include <switch.h>
Go to the source code of this file.
Data Structures | |
struct | switch_audio_resampler_t |
An audio resampling handle. More... | |
Macros | |
#define | switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4; |
#define | switch_normalize_volume_granular(x) if (x > 13) x = 13; if (x < -13) x = -13; |
#define | SWITCH_RESAMPLE_QUALITY 2 |
#define | switch_resample_create(_n, _fr, _tr, _ts, _q, _c) switch_resample_perform_create(_n, _fr, _tr, _ts, _q, _c, __FILE__, __SWITCH_FUNC__, __LINE__) |
#define | switch_resample_calc_buffer_size(_to, _from, _srclen) ((uint32_t)(((float)_to / (float)_from) * (float)_srclen) * 2) |
Functions | |
switch_status_t | switch_resample_perform_create (switch_audio_resampler_t **new_resampler, uint32_t from_rate, uint32_t to_rate, uint32_t to_size, int quality, uint32_t channels, const char *file, const char *func, int line) |
Prepare a new resampler handle. More... | |
void | switch_resample_destroy (switch_audio_resampler_t **resampler) |
Destroy an existing resampler handle. More... | |
uint32_t | switch_resample_process (switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen) |
Resample one float buffer into another using specifications of a given handle. More... | |
switch_size_t | switch_float_to_short (float *f, short *s, switch_size_t len) |
Convert an array of floats to an array of shorts. More... | |
int | switch_char_to_float (char *c, float *f, int len) |
Convert an array of chars to an array of floats. More... | |
int | switch_float_to_char (float *f, char *c, int len) |
Convert an array of floats to an array of chars. More... | |
int | switch_short_to_float (short *s, float *f, int len) |
Convert an array of shorts to an array of floats. More... | |
void | switch_swap_linear (int16_t *buf, int len) |
Perform a byteswap on a buffer of 16 bit samples. More... | |
void | switch_generate_sln_silence (int16_t *data, uint32_t samples, uint32_t channels, uint32_t divisor) |
Generate static noise. More... | |
void | switch_change_sln_volume (int16_t *data, uint32_t samples, int32_t vol) |
Change the volume of a signed linear audio frame. More... | |
void | switch_change_sln_volume_granular (int16_t *data, uint32_t samples, int32_t vol) |
Change the volume of a signed linear audio frame with more granularity. More... | |
uint32_t | switch_merge_sln (int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples, int channels) |
uint32_t | switch_unmerge_sln (int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples, int channels) |
void | switch_mux_channels (int16_t *data, switch_size_t samples, uint32_t orig_channels, uint32_t channels) |
Audio Resample Code.
This module implements a generic interface for doing audio resampling it currently uses libresample but can be ported to any resample library with a little effort. I decided against making this interface pluggable because there are not many options in terms of resample libraries so it seemed like a waste but I did opt to frontend the interface in case a better way comes along some day. =D
Definition in file switch_resample.h.
Definition at line 41 of file switch_resample.h.
Referenced by switch_change_sln_volume(), and switch_ivr_process_fh().
Definition at line 42 of file switch_resample.h.
Referenced by switch_change_sln_volume_granular().
#define switch_resample_calc_buffer_size | ( | _to, | |
_from, | |||
_srclen | |||
) | ((uint32_t)(((float)_to / (float)_from) * (float)_srclen) * 2) |
Definition at line 178 of file switch_resample.h.
Referenced by switch_core_session_write_frame(), switch_resample_perform_create(), and switch_resample_process().
#define SWITCH_RESAMPLE_QUALITY 2 |
Definition at line 46 of file switch_resample.h.
Referenced by switch_core_asr_feed(), switch_core_file_read(), switch_core_file_write(), switch_core_session_read_frame(), switch_core_session_write_frame(), and switch_core_speech_read_tts().
uint32_t switch_merge_sln | ( | int16_t * | data, |
uint32_t | samples, | ||
int16_t * | other_data, | ||
uint32_t | other_samples, | ||
int | channels | ||
) |
Definition at line 231 of file switch_resample.c.
References switch_normalize_to_16bit.
Referenced by eavesdrop_callback().
void switch_mux_channels | ( | int16_t * | data, |
switch_size_t | samples, | ||
uint32_t | orig_channels, | ||
uint32_t | channels | ||
) |
Definition at line 274 of file switch_resample.c.
References switch_assert, switch_normalize_to_16bit, and switch_zmalloc.
Referenced by switch_core_file_read(), switch_core_session_read_frame(), switch_core_session_write_frame(), switch_core_speech_read_tts(), switch_ivr_eavesdrop_session(), and teletone_handler().
uint32_t switch_unmerge_sln | ( | int16_t * | data, |
uint32_t | samples, | ||
int16_t * | other_data, | ||
uint32_t | other_samples, | ||
int | channels | ||
) |
Definition at line 254 of file switch_resample.c.
Referenced by switch_core_session_read_frame().