diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-08-14 16:17:38 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-08-14 16:17:38 +0000 |
| commit | 687a95b4b62136f54ea6b0930b6ba5e73291d2b2 (patch) | |
| tree | 5b93da9ac8cc82e75026a8f324cba4d9fcf8ab50 /src/plugins/Input/modplug/decoder_modplug.cpp | |
| parent | 4ccbc35ad14eaf86c56322c4155de109735ca60d (diff) | |
| download | qmmp-687a95b4b62136f54ea6b0930b6ba5e73291d2b2.tar.gz qmmp-687a95b4b62136f54ea6b0930b6ba5e73291d2b2.tar.bz2 qmmp-687a95b4b62136f54ea6b0930b6ba5e73291d2b2.zip | |
modplug plugin: preamp support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@498 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/modplug/decoder_modplug.cpp')
| -rw-r--r-- | src/plugins/Input/modplug/decoder_modplug.cpp | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp index 26a959e1c..ea0d18f64 100644 --- a/src/plugins/Input/modplug/decoder_modplug.cpp +++ b/src/plugins/Input/modplug/decoder_modplug.cpp @@ -18,6 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/* Based on Modplug XMMS Plugin + * Authors: Kenton Varda <temporal@gauge3d.org> + */ + #include <QObject> #include <QIODevice> #include <QFile> @@ -144,7 +148,7 @@ bool DecoderModPlug::initialize() QString filename = qobject_cast<QFile*>(input())->fileName (); ArchiveReader reader(this); - if(reader.isSupported(filename)) + if (reader.isSupported(filename)) { input()->close(); m_input_buf = reader.unpack(filename); @@ -217,6 +221,8 @@ void DecoderModPlug::run() mutex()->unlock(); dispatch(DecoderState::Decoding); + char *prebuf = new char[m_bks]; + while (! m_done && ! m_finish) { mutex()->lock (); @@ -239,7 +245,43 @@ void DecoderModPlug::run() // decode len = m_bks > (globalBufferSize - m_output_at) ? globalBufferSize - m_output_at : m_bks; - len = m_soundFile->Read (m_output_buf + m_output_at, len) * m_sampleSize; + len = m_soundFile->Read (prebuf, len) * m_sampleSize; + + //preamp + if (m_usePreamp) + { + { + //apply preamp + if (m_bps == 16) + { + uint n = len >> 1; + for (uint i = 0; i < n; i++) + { + short old = ((short*)prebuf)[i]; + ((short*)prebuf)[i] *= m_preampFactor; + // detect overflow and clip! + if ((old & 0x8000) != + (((short*)prebuf)[i] & 0x8000)) + ((short*)prebuf)[i] = old | 0x7FFF; + + } + } + else + { + for (uint i = 0; i < len; i++) + { + uchar old = ((uchar*)prebuf)[i]; + ((uchar*)prebuf)[i] *= m_preampFactor; + // detect overflow and clip! + if ((old & 0x80) != + (((uchar*)prebuf)[i] & 0x80)) + ((uchar*)prebuf)[i] = old | 0x7F; + } + } + } + } + + memmove(m_output_buf + m_output_at, prebuf, len); if (len > 0) { @@ -292,7 +334,7 @@ void DecoderModPlug::run() dispatch(DecoderState::Stopped); mutex()->unlock(); - + delete prebuf; deinit(); } @@ -348,12 +390,11 @@ void DecoderModPlug::readSettings() //general - /* - ui.amigaCheckBox->setChecked(settings.value("GrabAmigaMOD", TRUE).toBool());*/ - //resampling frequency + /* + settings.value("GrabAmigaMOD", TRUE).toBool());*/ //preamp - //ui.preampGroupBox->setChecked(settings.value("PreAmp", FALSE).toBool()); - //ui.preampSlider->setValue(int(settings.value("PreAmpLevel", 0.0f).toDouble()*10)); + m_usePreamp = settings.value("PreAmp", FALSE).toBool(); + m_preampFactor = exp(settings.value("PreAmpLevel", 0.0f).toDouble()); settings.endGroup(); } |
