diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 13:07:37 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 13:07:37 +0000 |
| commit | 73109017fa5b8c75166d513ef10a7972fb021896 (patch) | |
| tree | 74e8f75645b8334e1513151ee6369ddb95cde723 | |
| parent | 589fdd74490ce92d5532a89726e26d9966e10d91 (diff) | |
| download | qmmp-73109017fa5b8c75166d513ef10a7972fb021896.tar.gz qmmp-73109017fa5b8c75166d513ef10a7972fb021896.tar.bz2 qmmp-73109017fa5b8c75166d513ef10a7972fb021896.zip | |
enabled software volume control
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5905 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmp/outputwriter.cpp | 24 | ||||
| -rw-r--r-- | src/qmmp/volumecontrol.cpp | 100 | ||||
| -rw-r--r-- | src/qmmp/volumecontrol_p.h | 4 |
3 files changed, 15 insertions, 113 deletions
diff --git a/src/qmmp/outputwriter.cpp b/src/qmmp/outputwriter.cpp index b1c04d914..3d8358aa4 100644 --- a/src/qmmp/outputwriter.cpp +++ b/src/qmmp/outputwriter.cpp @@ -31,28 +31,6 @@ extern "C" { #include "equ/iir.h" } -//static functions -static inline void s8_to_s16(qint8 *in, qint16 *out, qint64 samples) -{ - for(qint64 i = 0; i < samples; ++i) - out[i] = in[i] << 8; - return; -} - -static inline void s24_to_s16(qint32 *in, qint16 *out, qint64 samples) -{ - for(qint64 i = 0; i < samples; ++i) - out[i] = in[i] >> 8; - return; -} - -static inline void s32_to_s16(qint32 *in, qint16 *out, qint64 samples) -{ - for(qint64 i = 0; i < samples; ++i) - out[i] = in[i] >> 16; - return; -} - OutputWriter::OutputWriter (QObject* parent) : QThread (parent) { m_handler = StateHandler::instance(); @@ -342,7 +320,7 @@ void OutputWriter::run() mutex()->unlock(); dispatchVisual(b); if (SoftwareVolume::instance()) - SoftwareVolume::instance()->changeVolume(b, m_channels, m_format); + SoftwareVolume::instance()->changeVolume(b, m_channels); if (m_muted) memset(b->data, 0, b->size * sizeof(float)); if(m_channel_converter) diff --git a/src/qmmp/volumecontrol.cpp b/src/qmmp/volumecontrol.cpp index a853334f6..aa5a59238 100644 --- a/src/qmmp/volumecontrol.cpp +++ b/src/qmmp/volumecontrol.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2013 by Ilya Kotov * + * Copyright (C) 2008-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -189,99 +189,23 @@ VolumeSettings SoftwareVolume::volume() const return v; } -void SoftwareVolume::changeVolume(Buffer *b, int chan, Qmmp::AudioFormat format) +void SoftwareVolume::changeVolume(Buffer *b, int chan) { - /*int samples = 0; - qint32 sample1 = 0; - qint32 sample2 = 0; - switch(format) + if(chan == 1) { - case Qmmp::PCM_S8: - samples = b->nbytes; - if (chan > 1) + for(size_t i = 0; i < b->samples; ++i) { - for (int i = 0; i < samples; i+=2) - { - ((char*)b->data)[i]*= m_scaleLeft; - ((char*)b->data)[i+1]*= m_scaleRight; - } - } - else - { - for (int i = 0; i < samples; i++) - ((char*)b->data)[i]*= qMax(m_scaleRight, m_scaleLeft); - } - case Qmmp::PCM_S16LE: - samples = b->nbytes/2; - if (chan > 1) - { - for (int i = 0; i < samples; i+=2) - { - ((short*)b->data)[i]*= m_scaleLeft; - ((short*)b->data)[i+1]*= m_scaleRight; - } + b->data[i] *= qMax(m_scaleLeft, m_scaleRight); } - else - { - for (int i = 0; i < samples; i++) - ((short*)b->data)[i]*= qMax(m_scaleRight, m_scaleLeft); - } - break; - case Qmmp::PCM_S24LE: - samples = b->nbytes/4; - if (chan > 1) - { - for (qint64 i = 0; i < samples; i+=2) - { - sample1 = ((qint32*)b->data)[i]; - sample2 = ((qint32*)b->data)[i+1]; - - if (sample1 & 0x800000) - sample1 |= 0xff000000; - - if (sample2 & 0x800000) - sample2 |= 0xff000000; - - sample1 *= m_scaleLeft; - sample2 *= m_scaleRight; - - ((qint32*)b->data)[i] = sample1; - ((qint32*)b->data)[i+1] = sample2; - } - } - else - { - for (qint64 i = 0; i < samples; i++) - { - sample1 = ((qint32*)b->data)[i]; - sample1 *= qMax(m_scaleRight, m_scaleLeft); - - if (sample1 & 0x800000) - sample1 |= 0xff000000; - - ((qint32*)b->data)[i] = sample1; - } - } - break; - case Qmmp::PCM_S32LE: - samples = b->nbytes/4; - if (chan > 1) - { - for (qint64 i = 0; i < samples; i+=2) - { - ((qint32*)b->data)[i]*= m_scaleLeft; - ((qint32*)b->data)[i+1]*= m_scaleRight; - } - } - else + } + else + { + for(size_t i = 0; i < b->samples; i+=2) { - for (qint64 i = 0; i < samples; i++) - ((qint32*)b->data)[i]*= qMax(m_scaleRight, m_scaleLeft); + b->data[i] *= m_scaleLeft; + b->data[i+1] *= m_scaleRight; } - break; - default: - ; - }*/ + } } //static diff --git a/src/qmmp/volumecontrol_p.h b/src/qmmp/volumecontrol_p.h index 12b8c8493..046e441a7 100644 --- a/src/qmmp/volumecontrol_p.h +++ b/src/qmmp/volumecontrol_p.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2012 by Ilya Kotov * + * Copyright (C) 2008-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -131,7 +131,7 @@ public: void setVolume(const VolumeSettings &v); VolumeSettings volume() const; - void changeVolume(Buffer *b, int chan, Qmmp::AudioFormat format); + void changeVolume(Buffer *b, int chan); static SoftwareVolume *instance(); |
