diff options
author | Christian Strømme <christian.stromme@digia.com> | 2013-11-12 04:01:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-02 18:05:52 +0100 |
commit | 14f31c29cf0bc78f66064306a91d3cb69677f542 (patch) | |
tree | 00f4c3dbbca6c3ecd2a8d01e5fba4077ec891a8b /src/plugins/opensles | |
parent | dd11f6d0527bfac17d855909397f66fe816a0d1f (diff) |
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 <yoann.lopes@digia.com>
Diffstat (limited to 'src/plugins/opensles')
-rw-r--r-- | src/plugins/opensles/qopenslesaudiooutput.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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 |