3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2016 Christian Schoenebeck * |
* Copyright (C) 2005 - 2017 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
100 |
} |
} |
101 |
|
|
102 |
/** |
/** |
103 |
* Calculates the line ratio value representation (linear scale) |
* Calculates the linear ratio value representation (linear scale) |
104 |
* of the @a decibel value provided (exponential scale). |
* of the @a decibel value provided (exponential scale). |
105 |
* |
* |
106 |
* The context of audio acoustic sound pressure levels is assumed, and |
* The context of audio acoustic sound pressure levels is assumed, and |
110 |
* |
* |
111 |
* @param decibel - sound pressure level in dB |
* @param decibel - sound pressure level in dB |
112 |
* @returns linear ratio of the supplied dB value |
* @returns linear ratio of the supplied dB value |
113 |
|
* @see LinRatioToDecibel() as inverse function |
114 |
*/ |
*/ |
115 |
static float DecibelToLinRatio(float decibel) { |
static float DecibelToLinRatio(float decibel) { |
116 |
return powf(10.f, decibel / 20.f); |
return powf(10.f, decibel / 20.f); |
117 |
} |
} |
118 |
|
|
119 |
/** |
/** |
120 |
|
* Calculates the decibel value (exponential scale) of the @a linear |
121 |
|
* ratio value representation (linear scale) provided. |
122 |
|
* |
123 |
|
* The context of audio acoustic sound pressure levels is assumed, and |
124 |
|
* hence the field version of the dB unit is used here (which uses a |
125 |
|
* linear factor of 20). This function is a bit slow, so it should |
126 |
|
* not be called too frequently. |
127 |
|
* |
128 |
|
* @param linear - sound pressure level as linear ratio value (linear scale) |
129 |
|
* @returns dB value representation |
130 |
|
* @see DecibelToLinRatio() as inverse function |
131 |
|
*/ |
132 |
|
static float LinRatioToDecibel(float linear) { |
133 |
|
return 20.f * log10f(linear); |
134 |
|
} |
135 |
|
|
136 |
|
/** |
137 |
* Calculates the relatively summed average of a set of values. |
* Calculates the relatively summed average of a set of values. |
138 |
* |
* |
139 |
* @param current - the current avaerage value of all previously summed values |
* @param current - the current avaerage value of all previously summed values |