SAF
Loading...
Searching...
No Matches
ambi_drc_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-2018 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
40#ifndef __AMBI_DRC_INTERNAL_H_INCLUDED__
41#define __AMBI_DRC_INTERNAL_H_INCLUDED__
42
43#include "ambi_drc.h" /* Include header for this example */
44#include "saf.h" /* Main include header for SAF */
45#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
46
47#ifdef __cplusplus
48extern "C" {
49#endif /* __cplusplus */
50
51/* ========================================================================== */
52/* Internal Parameters */
53/* ========================================================================== */
54
55#if !defined(AMBI_DRC_FRAME_SIZE)
56# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
57# define AMBI_DRC_FRAME_SIZE ( FRAME_SIZE )
58# else /* Otherwise, the default framesize for this example is: */
59# define AMBI_DRC_FRAME_SIZE ( 128 )
60# endif
61#endif
62#define HOP_SIZE ( 128 )
63#define HYBRID_BANDS ( HOP_SIZE + 5 )
64#define TIME_SLOTS ( AMBI_DRC_FRAME_SIZE / HOP_SIZE )
66/* Checks: */
67#if (AMBI_DRC_FRAME_SIZE % HOP_SIZE != 0)
68# error "AMBI_DRC_FRAME_SIZE must be an integer multiple of HOP_SIZE"
69#endif
70
71/* ========================================================================== */
72/* Structures */
73/* ========================================================================== */
74
79typedef struct _ambi_drc
80{
81 /* audio buffers and afSTFT handle */
82 float** frameTD;
83 float_complex*** inputFrameTF;
84 float_complex*** outputFrameTF;
85 void* hSTFT;
86 float freqVector[HYBRID_BANDS];
88 /* internal */
89 int nSH;
90 int new_nSH;
91 float fs;
92 float yL_z1[HYBRID_BANDS];
95#ifdef ENABLE_TF_DISPLAY
96 int wIdx;
97 int rIdx;
98 int storeIdx;
99 float** gainsTF_bank0;
100 float** gainsTF_bank1;
101#endif
102
103 /* user parameters */
104 float theshold;
105 float ratio;
106 float knee;
107 float inGain;
108 float outGain;
109 float attack_ms;
116
117
118/* ========================================================================== */
119/* Internal Functions */
120/* ========================================================================== */
121
123float ambi_drc_gainComputer(float xG, float T, float R, float W);
124
126float ambi_drc_smoothPeakDetector(float xL, float yL_z1, float alpha_a, float alpha_r);
127
129void ambi_drc_initTFT(void* const hAmbi);
130
132void ambi_drc_setInputOrder(SH_ORDERS inOrder, int* nSH);
133
134
135#ifdef __cplusplus
136} /* extern "C" */
137#endif/* __cplusplus */
138
139#endif /* __AMBI_DRC_INTERNAL_H_INCLUDED__ */
NORM_TYPES
Available Ambisonic normalisation conventions.
Definition _common.h:74
CH_ORDER
Available Ambisonic channel ordering conventions.
Definition _common.h:59
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
Definition _common.h:38
#define HYBRID_BANDS
Number of frequency bands.
A frequency-dependent Ambisonic sound scene dynamic range compressor (DRC)
void ambi_drc_setInputOrder(SH_ORDERS inOrder, int *nSH)
Sets the internal input order.
float ambi_drc_gainComputer(float xG, float T, float R, float W)
The DRC gain computer.
void ambi_drc_initTFT(void *const hAmbi)
Initialise the filterbank used by ambi_drc.
float ambi_drc_smoothPeakDetector(float xL, float yL_z1, float alpha_a, float alpha_r)
The envelope detector.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Main structure for ambi_drc.
float ratio
Compression ratio.
float attack_ms
Attack time, in ms.
float knee
Knee width, in dB.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
int reInitTFT
0: no init required, 1: init required, 2: init in progress
SH_ORDERS currentOrder
Current input SH order.
void * hSTFT
Time-frequency transform handle.
float ** frameTD
Input/output SH signals, in the time-domain; MAX_NUM_SH_SIGNALS x AMBI_DRC_FRAME_SIZE.
float_complex *** inputFrameTF
Input SH signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
float theshold
Threshold parameter, in dB.
float_complex *** outputFrameTF
Output SH signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS.
float outGain
Post-gain, in dB.
float inGain
Pre-gain, in dB.
int nSH
Current number of SH signals.
float release_ms
Release time, in ms.
int new_nSH
New number of SH signals (current value will be replaced by this after next re-init)
float fs
Host sampling rate, in Hz.