1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef SOFTVOL_CURVE_H_
7 #define SOFTVOL_CURVE_H_
8 
9 #include <math.h>
10 
11 #define LOG_10 2.302585
12 
13 struct cras_volume_curve;
14 
15 extern const float softvol_scalers[101];
16 
17 /* Returns the volume scaler in the soft volume curve for the given index. */
18 static inline float softvol_get_scaler(unsigned int volume_index)
19 {
20 	return softvol_scalers[volume_index];
21 }
22 
23 /* convert dBFS to softvol scaler */
24 static inline float convert_softvol_scaler_from_dB(long dBFS)
25 {
26 	return expf(LOG_10 * dBFS / 2000);
27 }
28 
29 /* Builds software volume scalers from volume curve. */
30 float *softvol_build_from_curve(const struct cras_volume_curve *curve);
31 
32 #endif /* SOFTVOL_CURVE_H_ */
33