1 /*
2  * Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
3  *
4  * This file is part of Zrythm
5  *
6  * Zrythm is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Zrythm is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with Zrythm.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * \file
22  *
23  * Balance control of stereo sources, mainly used
24  * in the mixer channels.
25  */
26 
27 #ifndef __AUDIO_BALANCE_CONTROL_H__
28 #define __AUDIO_BALANCE_CONTROL_H__
29 
30 /**
31  * @addtogroup audio
32  *
33  * @{
34  */
35 
36 /**
37  * See https://www.harmonycentral.com/articles/the-truth-about-panning-laws
38  */
39 typedef enum BalanceControlAlgorithm
40 {
41   /**
42    * Classic "Balance" mode.
43    *
44    * Attennuates one channel only with no positive
45    * gain.
46    *
47    * Examples:
48    * hard left: mute right channel, left channel
49    *   untouched.
50    * mid left: attenuate right channel by (signal *
51    *   pan - 0.5), left channel untouched.
52    */
53   BALANCE_CONTROL_ALGORITHM_LINEAR,
54 } BalanceControlAlgorithm;
55 
56 /**
57  * Returns the coefficients to multiply the L and
58  * R signal with.
59  */
60 void
61 balance_control_get_calc_lr (
62   BalanceControlAlgorithm algo,
63   float                   pan,
64   float *                 calc_l,
65   float *                 calc_r);
66 
67 /**
68  * @}
69  */
70 
71 #endif
72