From 14f31c29cf0bc78f66064306a91d3cb69677f542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 12 Nov 2013 04:01:28 +0100 Subject: OpenSL: Fix volume scale The old code was assuming that the interface was expecting power values, while it actually uses amplitude values. In addition the difference between the min/max values where used, resulting in quite high gain values. Task-number: QTBUG-34777 Change-Id: Ibd3f7774b67c44e37dfd79cbe6e2c35746f00a0a Reviewed-by: Yoann Lopes --- src/plugins/opensles/qopenslesaudiooutput.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/opensles') diff --git a/src/plugins/opensles/qopenslesaudiooutput.cpp b/src/plugins/opensles/qopenslesaudiooutput.cpp index 65c0f5a61..df91e6ff1 100644 --- a/src/plugins/opensles/qopenslesaudiooutput.cpp +++ b/src/plugins/opensles/qopenslesaudiooutput.cpp @@ -52,6 +52,8 @@ #define BUFFER_COUNT 2 #define DEFAULT_PERIOD_TIME_MS 50 #define MINIMUM_PERIOD_TIME_MS 5 +#define EBASE 2.302585093 +#define LOG10(x) qLn(x)/qreal(EBASE) QT_BEGIN_NAMESPACE @@ -622,7 +624,7 @@ inline SLmillibel QOpenSLESAudioOutput::adjustVolume(qreal vol) if (qFuzzyCompare(vol, qreal(1.0))) return 0; - return SL_MILLIBEL_MIN + ((1 - (qLn(10 - (vol * 10)) / qLn(10))) * SL_MILLIBEL_MAX); + return 20 * LOG10(vol) * 100; // I.e., 20 * LOG10(SL_MILLIBEL_MAX * vol / SL_MILLIBEL_MAX) } QT_END_NAMESPACE -- cgit v1.2.3