275 |
return true; |
return true; |
276 |
} |
} |
277 |
|
|
278 |
|
/** |
279 |
|
* Converts the volume value specified in percents to decibels. |
280 |
|
*/ |
281 |
|
public static double |
282 |
|
percentsToDecibels(int vol) { |
283 |
|
if(vol == 0) return Double.NEGATIVE_INFINITY; |
284 |
|
double i = vol; |
285 |
|
i /= 100; |
286 |
|
i = 20 * Math.log10(i); |
287 |
|
return i; |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
/** |
293 |
|
* Converts the volume value specified in decibels to percents. |
294 |
|
*/ |
295 |
|
public static int |
296 |
|
decibelsToPercents(double vol) { |
297 |
|
if(vol == Double.NEGATIVE_INFINITY) return 0; |
298 |
|
double i = Math.pow(10, vol/20); |
299 |
|
i *= 100; |
300 |
|
return (int)i; |
301 |
|
} |
302 |
|
|
303 |
|
/** |
304 |
|
* Converts the volume value specified in decibels to volume factor. |
305 |
|
*/ |
306 |
|
public static float |
307 |
|
decibelsToFactor(double vol) { |
308 |
|
if(vol == Double.NEGATIVE_INFINITY) return 0; |
309 |
|
double i = Math.pow(10, vol/20); |
310 |
|
return (float)i; |
311 |
|
} |
312 |
|
|
313 |
|
/** |
314 |
|
* Converts the volume value specified in percents to volume factor. |
315 |
|
*/ |
316 |
|
public static float |
317 |
|
percentsToFactor(int vol) { |
318 |
|
float f = vol; |
319 |
|
f /= 100; |
320 |
|
return f; |
321 |
|
} |
322 |
} |
} |