Asterisk - The Open Source Telephony Project
18.5.0
|
Multi-party software based binaural mixing. More...
#include "include/bridge_softmix_internal.h"
Go to the source code of this file.
Macros | |
#define | CONVOLUTION_SAMPLE_SIZE 960 |
#define | CONVOLVE_CHANNEL_PREALLOC 3 |
#define | CONVOLVE_MAX_BUFFER 4096 |
Functions | |
void | add_binaural_mixing (struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data, unsigned int softmix_samples, struct softmix_mixing_array *mixing_array, struct softmix_channel *sc, const char *channel_name) |
Processes audio data with the binaural synthesis and adds the result to the mixing array. More... | |
void | binaural_mixing (struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data, struct softmix_mixing_array *mixing_array, int16_t *bin_buf, int16_t *ann_buf) |
Mixes all binaural audio data contained in the mixing array. More... | |
void | check_binaural_position_change (struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data) |
Checks if a position change in the virual enviroment is requested by one of the participants. More... | |
void | create_binaural_frame (struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc, int16_t *bin_buf, int16_t *ann_buf, unsigned int softmix_datalen, unsigned int softmix_samples, int16_t *buf) |
Creates a frame out of binaural audio data. More... | |
int | do_convolve (struct convolve_channel *chan, int16_t *in_samples, unsigned int in_sample_size, unsigned int hrtf_length) |
Binaural convolving of audio data for a channel. More... | |
struct convolve_channel_pair * | do_convolve_pair (struct convolve_data *data, unsigned int pos_id, int16_t *in_samples, unsigned int in_sample_size, const char *channel_name) |
Binaural convolving of audio data for a channel pair (left and right channel). More... | |
void | free_convolve_channel (struct convolve_channel *cchan) |
Frees all data needed for binaural processing by an audio channel. More... | |
void | free_convolve_channel_pair (struct convolve_channel_pair *cchan_pair) |
Frees all data needed for binaural processing by a pair of audio channels (left and right). More... | |
void | free_convolve_data (struct convolve_data *data) |
Frees all channels and data needed for binaural audio processing. More... | |
float * | get_hrir (unsigned int chan_pos, unsigned int chan_side) |
Provides a head related impulse response for the given position in the virtual enviroment. More... | |
int | init_convolve_channel (struct convolve_channel *channel, unsigned int hrtf_len, unsigned int chan_pos, unsigned int chan_side, unsigned int default_sample_size) |
Initializes all data needed for binaural audio processing. More... | |
int | init_convolve_channel_pair (struct convolve_channel_pair *cchan_pair, unsigned int hrtf_len, unsigned int chan_pos, unsigned int default_sample_size) |
Initializies all data needed for binaural audio processing of a channel pair (left and right). More... | |
int | init_convolve_data (struct convolve_data *data, unsigned int default_sample_size) |
Preinits a specific number of channels (CONVOVLE_CHANNEL_PREALLOC) at the beginning of a conference. More... | |
void | random_binaural_pos_change (struct softmix_bridge_data *softmix_data) |
Randomly changes the virtual positions of conference participants. More... | |
void | reset_channel_pair (struct convolve_channel_pair *channel_pair, unsigned int default_sample_size) |
Deletes left over signals on a channel that it can be reused. More... | |
int | set_binaural_data_join (struct convolve_data *data, unsigned int default_sample_size) |
Joins a channel into a virtual enviroment build with the help of binaural sythesis. More... | |
void | set_binaural_data_leave (struct convolve_data *data, unsigned int pos, unsigned int default_sample_size) |
Removes a channel from the binaural conference bridge. Marks the position in the virtual room as unused that it can be reused by the next channel which enters the conference. More... | |
void | softmix_process_write_binaural_audio (struct softmix_channel *sc, unsigned int default_sample_size) |
Writes the binaural audio to a channel. More... | |
Multi-party software based binaural mixing.
Definition in file bridge_softmix_binaural.c.
#define CONVOLUTION_SAMPLE_SIZE 960 |
The default sample size in an binaural environment with a two-channel codec at 48kHz is 960 samples.
Definition at line 43 of file bridge_softmix_binaural.c.
Referenced by add_binaural_mixing(), and do_convolve().
#define CONVOLVE_CHANNEL_PREALLOC 3 |
The number of prealloced channels when a bridge will be created.
Definition at line 37 of file bridge_softmix_binaural.c.
Referenced by init_convolve_data().
#define CONVOLVE_MAX_BUFFER 4096 |
Max size of the convolve buffer.
Definition at line 39 of file bridge_softmix_binaural.c.
Referenced by init_convolve_channel().
void add_binaural_mixing | ( | struct ast_bridge * | bridge, |
struct softmix_bridge_data * | softmix_data, | ||
unsigned int | softmix_samples, | ||
struct softmix_mixing_array * | mixing_array, | ||
struct softmix_channel * | sc, | ||
const char * | channel_name | ||
) |
Processes audio data with the binaural synthesis and adds the result to the mixing array.
bridge | The conference bridge needed to check if binaural processing is active or not. |
softmix_data | Contains all data for the softmix bridge and for the binaural processing. |
softmix_samples | The sample size. |
mixing_array | The array which holds all audio data for mixing. |
sc | The channel which contains the audio data to process. |
channel_name | The name of the channel |
Definition at line 500 of file bridge_softmix_binaural.c.
References convolve_data::binaural_active, ast_bridge_softmix::binaural_active, softmix_channel::binaural_pos, softmix_mixing_array::buffers, softmix_mixing_array::chan_pairs, CONVOLUTION_SAMPLE_SIZE, softmix_bridge_data::convolve, do_convolve_pair(), softmix_channel::is_announcement, NULL, softmix_channel::our_chan_pair, ast_bridge::softmix, and softmix_mixing_array::used_entries.
Referenced by softmix_mixing_loop().
void binaural_mixing | ( | struct ast_bridge * | bridge, |
struct softmix_bridge_data * | softmix_data, | ||
struct softmix_mixing_array * | mixing_array, | ||
int16_t * | bin_buf, | ||
int16_t * | ann_buf | ||
) |
Mixes all binaural audio data contained in the mixing array.
bridge | The conference bridge needed to check if binaural processing is active or not. |
softmix_data | Contains all data for the softmix bridge and for the binaural processing. |
mixing_array | The array which holds all audio data for mixing. |
bin_buf | The buffer that will contain the mixing results. |
ann_buf | The buffer that will contain mixed announcements in an interleaved format. |
Definition at line 521 of file bridge_softmix_binaural.c.
References ast_slinear_saturated_add(), convolve_data::binaural_active, ast_bridge_softmix::binaural_active, softmix_mixing_array::buffers, convolve_channel_pair::chan_left, softmix_mixing_array::chan_pairs, convolve_channel_pair::chan_right, softmix_bridge_data::convolve, softmix_bridge_data::default_sample_size, MAX_DATALEN, NULL, convolve_channel::out_data, ast_bridge::softmix, and softmix_mixing_array::used_entries.
Referenced by softmix_mixing_loop().
void check_binaural_position_change | ( | struct ast_bridge * | bridge, |
struct softmix_bridge_data * | softmix_data | ||
) |
Checks if a position change in the virual enviroment is requested by one of the participants.
bridge | The conference bridge. |
softmix_data | The data used by the softmix bridge. |
Definition at line 467 of file bridge_softmix_binaural.c.
References ast_bridge_channel_lock_bridge(), ast_bridge_unlock, AST_LIST_TRAVERSE, convolve_data::binaural_active, ast_bridge_softmix::binaural_active, ast_bridge_channel::binaural_pos_change, ast_bridge_channel::bridge, ast_bridge::channels, softmix_bridge_data::convolve, random_binaural_pos_change(), and ast_bridge::softmix.
Referenced by softmix_mixing_loop().
void create_binaural_frame | ( | struct ast_bridge_channel * | bridge_channel, |
struct softmix_channel * | sc, | ||
int16_t * | bin_buf, | ||
int16_t * | ann_buf, | ||
unsigned int | softmix_datalen, | ||
unsigned int | softmix_samples, | ||
int16_t * | buf | ||
) |
Creates a frame out of binaural audio data.
bridge_channel | Contains the information if binaural processing is active or not. If active binaural audio data will be copied, if not mono data will be provided in an interleaved format. |
sc | The softmix channel holding all informations for the process. |
bin_buf | The buffer that contains all mixing results. |
ann_buf | The buffer that contains mixed announcements in an interleaved format. |
softmix_datalen | The size of the audio data. |
softmix_samples | The number of audio samples. |
buf | The buffer that contains all mono mixing results, used if binaural processing is inactive. |
Definition at line 553 of file bridge_softmix_binaural.c.
References softmix_channel::binaural_suspended, ast_bridge_channel::binaural_suspended, ast_frame::datalen, softmix_channel::final_buf, softmix_channel::is_announcement, ast_frame::samples, and softmix_channel::write_frame.
Referenced by softmix_mixing_loop().
int do_convolve | ( | struct convolve_channel * | chan, |
int16_t * | in_samples, | ||
unsigned int | in_sample_size, | ||
unsigned int | hrtf_length | ||
) |
Binaural convolving of audio data for a channel.
chan | The channel that will contain the binaural audio data as result. |
in_samples | The audio data which will be convolved. |
in_sample_size | The size of the audio data. |
hrtf_length | The length of the head related transfer function used to convolve the audio. |
0 | success |
-1 | failure |
Definition at line 86 of file bridge_softmix_binaural.c.
References CONVOLUTION_SAMPLE_SIZE, convolve_channel::fftw_in, convolve_channel::fftw_out, convolve_channel::hrtf, convolve_channel::out_data, and convolve_channel::overlap_add.
Referenced by do_convolve_pair().
struct convolve_channel_pair* do_convolve_pair | ( | struct convolve_data * | data, |
unsigned int | pos_id, | ||
int16_t * | in_samples, | ||
unsigned int | in_sample_size, | ||
const char * | channel_name | ||
) |
Binaural convolving of audio data for a channel pair (left and right channel).
data | Contains the left and right audio channel. |
pos_id | The position the channel has in the virtual enviroment. |
in_samples | The audio data which will be convolved for both channels. |
in_sample_size | The size of the audio data. |
channel_name | The name of the channel |
The | channel pair with convolved audio on success. |
NULL | failure |
Definition at line 145 of file bridge_softmix_binaural.c.
References ast_log, convolve_data::cchan_pair, convolve_channel_pair::chan_left, convolve_channel_pair::chan_right, do_convolve(), convolve_data::hrtf_length, LOG_ERROR, NULL, and convolve_data::pos_ids.
Referenced by add_binaural_mixing().
void free_convolve_channel | ( | struct convolve_channel * | cchan | ) |
Frees all data needed for binaural processing by an audio channel.
cchan | The channel to clean up. |
Definition at line 341 of file bridge_softmix_binaural.c.
References ast_free, convolve_channel::fftw_in, convolve_channel::fftw_out, convolve_channel::hrtf, convolve_channel::out_data, and convolve_channel::overlap_add.
Referenced by free_convolve_channel_pair(), and init_convolve_channel_pair().
void free_convolve_channel_pair | ( | struct convolve_channel_pair * | cchan_pair | ) |
Frees all data needed for binaural processing by a pair of audio channels (left and right).
cchan_pair | The channel pair to clean up. |
Definition at line 354 of file bridge_softmix_binaural.c.
References convolve_channel_pair::chan_left, convolve_channel_pair::chan_right, and free_convolve_channel().
Referenced by free_convolve_data(), and init_convolve_data().
void free_convolve_data | ( | struct convolve_data * | data | ) |
Frees all channels and data needed for binaural audio processing.
data | Contains all channels and data for the cleanup process. |
Definition at line 360 of file bridge_softmix_binaural.c.
References ast_free, convolve_data::cchan_pair, convolve_data::chan_size, free_convolve_channel_pair(), and convolve_data::pos_ids.
Referenced by softmix_bridge_destroy().
float* get_hrir | ( | unsigned int | chan_pos, |
unsigned int | chan_side | ||
) |
Provides a head related impulse response for the given position in the virtual enviroment.
chan_pos | The position of the channel in the virtual enviroment. |
chan_side | 0 for the left audio channel, 1 for the right. |
The | hrir for the given position in the virtual room for either the left or right channels. |
NULL | on failure. |
Definition at line 172 of file bridge_softmix_binaural.c.
References ast_binaural_positions, ast_log, HRIRS_CHANNEL_LEFT, HRIRS_CHANNEL_RIGHT, hrirs_left, hrirs_right, LOG_ERROR, and NULL.
Referenced by init_convolve_channel().
int init_convolve_channel | ( | struct convolve_channel * | channel, |
unsigned int | hrtf_len, | ||
unsigned int | chan_pos, | ||
unsigned int | chan_side, | ||
unsigned int | default_sample_size | ||
) |
Initializes all data needed for binaural audio processing.
channel | The channel used for binaural audio processing. |
hrtf_len | The length of the head related impulse response used for binaural processing. |
chan_pos | The position of the channel in the virtual enviroment. |
chan_side | 0 for the left audio channel, 1 for the right. |
default_sample_size | The default size of audio samples. |
0 | on success |
-1 | on failure |
Definition at line 188 of file bridge_softmix_binaural.c.
References ast_calloc, ast_free, CONVOLVE_MAX_BUFFER, convolve_channel::fftw_in, convolve_channel::fftw_out, get_hrir(), HRIRS_IMPULSE_LEN, HRIRS_IMPULSE_SIZE, convolve_channel::hrtf, NULL, convolve_channel::out_data, and convolve_channel::overlap_add.
Referenced by init_convolve_channel_pair().
int init_convolve_channel_pair | ( | struct convolve_channel_pair * | cchan_pair, |
unsigned int | hrtf_len, | ||
unsigned int | chan_pos, | ||
unsigned int | default_sample_size | ||
) |
Initializies all data needed for binaural audio processing of a channel pair (left and right).
cchan_pair | The channel pair used for binaural audio processing. |
hrtf_len | The length of the head related impulse response used for binaural processing. |
chan_pos | The position of the channel in the virtual enviroment. |
default_sample_size | The default size of audio samples. |
0 | on success |
-1 | on failure |
Definition at line 260 of file bridge_softmix_binaural.c.
References ast_debug, ast_log, convolve_channel_pair::chan_left, convolve_channel_pair::chan_right, free_convolve_channel(), HRIRS_CHANNEL_LEFT, HRIRS_CHANNEL_RIGHT, init_convolve_channel(), and LOG_ERROR.
Referenced by init_convolve_data(), and set_binaural_data_join().
int init_convolve_data | ( | struct convolve_data * | data, |
unsigned int | default_sample_size | ||
) |
Preinits a specific number of channels (CONVOVLE_CHANNEL_PREALLOC) at the beginning of a conference.
data | Contains all channels and data needed for binaural processing (e.g. head related transfer functions). |
default_sample_size | The default size of audio samples. |
0 | on success |
-1 | on failure |
Definition at line 290 of file bridge_softmix_binaural.c.
References ast_calloc, ast_free, ast_malloc, convolve_data::cchan_pair, convolve_data::chan_size, CONVOLVE_CHANNEL_PREALLOC, free_convolve_channel_pair(), convolve_data::hrtf_length, init_convolve_channel_pair(), NULL, convolve_data::number_channels, and convolve_data::pos_ids.
Referenced by softmix_mixing_thread().
void random_binaural_pos_change | ( | struct softmix_bridge_data * | softmix_data | ) |
Randomly changes the virtual positions of conference participants.
softmix_data | The structure containing all position informations. |
Definition at line 61 of file bridge_softmix_binaural.c.
References convolve_data::cchan_pair, convolve_data::chan_size, softmix_bridge_data::convolve, softmix_bridge_data::default_sample_size, NULL, reset_channel_pair(), and tmp().
Referenced by check_binaural_position_change().
void reset_channel_pair | ( | struct convolve_channel_pair * | channel_pair, |
unsigned int | default_sample_size | ||
) |
Deletes left over signals on a channel that it can be reused.
channel_pair | The channel pair which contains the left and right audio channel. |
default_sample_size | The sample size which the channel pair uses. |
Definition at line 54 of file bridge_softmix_binaural.c.
References convolve_channel_pair::chan_left, convolve_channel_pair::chan_right, and convolve_channel::overlap_add.
Referenced by random_binaural_pos_change(), and set_binaural_data_leave().
int set_binaural_data_join | ( | struct convolve_data * | data, |
unsigned int | default_sample_size | ||
) |
Joins a channel into a virtual enviroment build with the help of binaural sythesis.
data | Contains all channels and data needed for binaural processing (e.g. head related transfer functions). |
default_sample_size | The default size of audio samples. |
The | position of the channel in the virtual enviroment. |
-1 | on failure |
Definition at line 371 of file bridge_softmix_binaural.c.
References ast_malloc, ast_realloc, convolve_data::cchan_pair, convolve_data::chan_size, convolve_data::hrtf_length, init_convolve_channel_pair(), NULL, convolve_data::number_channels, and convolve_data::pos_ids.
Referenced by softmix_bridge_join().
void set_binaural_data_leave | ( | struct convolve_data * | data, |
unsigned int | pos, | ||
unsigned int | default_sample_size | ||
) |
Removes a channel from the binaural conference bridge. Marks the position in the virtual room as unused that it can be reused by the next channel which enters the conference.
data | Contains all channels and data needed for binaural processing (e.g. head related transfer functions). |
pos | The position of the channel in the virtual enviroment. |
default_sample_size | The default size of audio samples. |
Definition at line 428 of file bridge_softmix_binaural.c.
References convolve_data::cchan_pair, convolve_data::chan_size, convolve_data::number_channels, convolve_data::pos_ids, and reset_channel_pair().
Referenced by softmix_bridge_leave().
void softmix_process_write_binaural_audio | ( | struct softmix_channel * | sc, |
unsigned int | default_sample_size | ||
) |
Writes the binaural audio to a channel.
sc | The softmix channel. |
default_sample_size | The default size of audio samples. |
Definition at line 440 of file bridge_softmix_binaural.c.
References ast_slinear_saturated_subtract(), softmix_channel::binaural_suspended, convolve_channel_pair::chan_left, convolve_channel_pair::chan_right, softmix_channel::final_buf, softmix_channel::our_buf, softmix_channel::our_chan_pair, convolve_channel::out_data, ast_frame::samples, and softmix_channel::write_frame.
Referenced by softmix_process_write_audio().