aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-12-27 11:09:46 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-12-27 11:09:46 +0000
commitb5dc393952c84dbd53c60afb8d367ad99bbd16ca (patch)
treed8c1ffc992fa60391f04179550a946a056b9b4de
parentd8525aed2bc18ac54e65a996d38df934966c0c7c (diff)
downloadqmmp-b5dc393952c84dbd53c60afb8d367ad99bbd16ca.tar.gz
qmmp-b5dc393952c84dbd53c60afb8d367ad99bbd16ca.tar.bz2
qmmp-b5dc393952c84dbd53c60afb8d367ad99bbd16ca.zip
ported all effect plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5899 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/Effect/CMakeLists.txt6
-rw-r--r--src/plugins/Effect/Effect.pro4
-rw-r--r--src/plugins/Effect/crossfade/crossfadeplugin.cpp54
-rw-r--r--src/plugins/Effect/crossfade/crossfadeplugin.h15
-rw-r--r--src/plugins/Effect/ladspa/ladspahelper.cpp10
-rw-r--r--src/plugins/Effect/ladspa/ladspahelper.h4
-rw-r--r--src/plugins/Effect/ladspa/ladspahost.cpp41
-rw-r--r--src/plugins/Effect/ladspa/ladspahost.h9
-rw-r--r--src/plugins/Effect/stereo/stereoplugin.cpp44
-rw-r--r--src/plugins/Effect/stereo/stereoplugin.h5
10 files changed, 74 insertions, 118 deletions
diff --git a/src/plugins/Effect/CMakeLists.txt b/src/plugins/Effect/CMakeLists.txt
index 85a8577ec..1b9517799 100644
--- a/src/plugins/Effect/CMakeLists.txt
+++ b/src/plugins/Effect/CMakeLists.txt
@@ -13,13 +13,13 @@ add_subdirectory(bs2b)
ENDIF(USE_BS2B)
IF(USE_LADSPA)
-#add_subdirectory(ladspa)
+add_subdirectory(ladspa)
ENDIF(USE_LADSPA)
IF(USE_CROSSFADE)
-#add_subdirectory(crossfade)
+add_subdirectory(crossfade)
ENDIF(USE_CROSSFADE)
IF(USE_STEREO)
-#add_subdirectory(stereo)
+add_subdirectory(stereo)
ENDIF(USE_STEREO)
diff --git a/src/plugins/Effect/Effect.pro b/src/plugins/Effect/Effect.pro
index 2b686db6e..336647a4b 100644
--- a/src/plugins/Effect/Effect.pro
+++ b/src/plugins/Effect/Effect.pro
@@ -1,7 +1,7 @@
include (../../../qmmp.pri)
TEMPLATE = subdirs
-#SUBDIRS += crossfade stereo
+SUBDIRS += crossfade stereo
contains(CONFIG, BS2B_PLUGIN){
SUBDIRS += bs2b
@@ -10,6 +10,6 @@ SUBDIRS += bs2b
unix {
SUBDIRS += srconverter
contains(CONFIG, LADSPA_PLUGIN){
-# SUBDIRS += ladspa
+ SUBDIRS += ladspa
}
}
diff --git a/src/plugins/Effect/crossfade/crossfadeplugin.cpp b/src/plugins/Effect/crossfade/crossfadeplugin.cpp
index 7176433ed..c7059cd6e 100644
--- a/src/plugins/Effect/crossfade/crossfadeplugin.cpp
+++ b/src/plugins/Effect/crossfade/crossfadeplugin.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2014 by Ilya Kotov <forkotov02@hotmail.ru> *
+ * Copyright (C) 2009-2015 by Ilya Kotov <forkotov02@hotmail.ru> *
* Copyright (C) 2009 by Sebastian Pipping <sebastian@pipping.org> *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -63,14 +63,14 @@ void CrossfadePlugin::applyEffect(Buffer *b)
case PREPARING:
if(m_core->totalTime() && (m_core->totalTime() - m_handler->elapsed() < m_overlap))
{
- if(m_buffer_at + b->nbytes > m_buffer_size)
+ if(m_buffer_at + b->samples > m_buffer_size)
{
- m_buffer_size = m_buffer_at + b->nbytes;
- m_buffer = (uchar *)realloc(m_buffer, m_buffer_size);
+ m_buffer_size = m_buffer_at + b->samples;
+ m_buffer = (float *)realloc(m_buffer, m_buffer_size * sizeof(float));
}
- memcpy(m_buffer + m_buffer_at, b->data, b->nbytes);
- m_buffer_at += b->nbytes;
- b->nbytes = 0;
+ memcpy(m_buffer + m_buffer_at, b->data, b->samples * sizeof(float));
+ m_buffer_at += b->samples;
+ b->samples = 0;
return;
}
else if(m_buffer_at > 0)
@@ -81,17 +81,10 @@ void CrossfadePlugin::applyEffect(Buffer *b)
if (m_buffer_at > 0)
{
double volume = (double)m_buffer_at/m_buffer_size;
- uint size = qMin((ulong)m_buffer_at, b->nbytes);
-
- if(format() == Qmmp::PCM_S16LE)
- mix16(b->data, m_buffer, size >> 1, volume);
- else if(format() == Qmmp::PCM_S8)
- mix8(b->data, m_buffer, size, volume);
- else //PCM_24LE, PCM_32LE
- mix32(b->data, m_buffer, size >> 2, volume);
-
- m_buffer_at -= size;
- memmove(m_buffer, m_buffer + size, m_buffer_at);
+ size_t samples = qMin(m_buffer_at, b->samples);
+ mix(b->data, m_buffer, samples, volume);
+ m_buffer_at -= samples;
+ memmove(m_buffer, m_buffer + samples, m_buffer_at * sizeof(float));
}
else
m_state = WAITING;
@@ -101,31 +94,16 @@ void CrossfadePlugin::applyEffect(Buffer *b)
return;
}
-void CrossfadePlugin::configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format)
-{
- Effect::configure(freq, map, format);
-}
-
-void CrossfadePlugin::mix8(uchar *cur_buf, uchar *prev_buf, uint samples, double volume)
-{
- for (uint i = 0; i < samples; i++)
- {
- cur_buf[i] = cur_buf[i]*(1.0 - volume)+prev_buf[i]*volume;
- }
-}
-
-void CrossfadePlugin::mix16(uchar *cur_buf, uchar *prev_buf, uint samples, double volume)
+void CrossfadePlugin::configure(quint32 freq, ChannelMap map)
{
- for (uint i = 0; i < samples; i++)
- {
- ((short*)cur_buf)[i] =((short*)cur_buf)[i]*(1.0 - volume)+((short*)prev_buf)[i]*volume;
- }
+ Effect::configure(freq, map);
}
-void CrossfadePlugin::mix32(uchar *cur_buf, uchar *prev_buf, uint samples, double volume)
+void CrossfadePlugin::mix(float *cur_buf, float *prev_buf, uint samples, double volume)
{
for (uint i = 0; i < samples; i++)
{
- ((qint32*)cur_buf)[i] =((qint32*)cur_buf)[i]*(1.0 - volume)+((qint32*)prev_buf)[i]*volume;
+ cur_buf[i] = cur_buf[i]*(1.0 - volume) + prev_buf[i]*volume;
+ cur_buf[i] = qBound(-1.0f, cur_buf[i], 1.0f);
}
}
diff --git a/src/plugins/Effect/crossfade/crossfadeplugin.h b/src/plugins/Effect/crossfade/crossfadeplugin.h
index 065369b1b..229756b76 100644
--- a/src/plugins/Effect/crossfade/crossfadeplugin.h
+++ b/src/plugins/Effect/crossfade/crossfadeplugin.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2014 by Ilya Kotov *
+ * Copyright (C) 2010-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -21,6 +21,7 @@
#define CROSSFADEPLUGIN_H
#include <QMutex>
+#include <stddef.h>
#include <qmmp/effect.h>
class SoundCore;
@@ -38,7 +39,7 @@ public:
virtual ~CrossfadePlugin();
void applyEffect(Buffer *b);
- void configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format);
+ void configure(quint32 freq, ChannelMap map);
private:
enum State
@@ -49,13 +50,11 @@ private:
PROCESSING,
};
- void mix8(uchar *cur_buf, uchar *prev_buf, uint samples, double volume);
- void mix16(uchar *cur_buf, uchar *prev_buf, uint samples, double volume);
- void mix32(uchar *cur_buf, uchar *prev_buf, uint samples, double volume);
+ void mix(float *cur_buf, float *prev_buf, uint samples, double volume);
- uchar *m_buffer;
- ulong m_buffer_at;
- ulong m_buffer_size;
+ float *m_buffer;
+ size_t m_buffer_at;
+ size_t m_buffer_size;
qint64 m_overlap;
int m_state;
SoundCore *m_core;
diff --git a/src/plugins/Effect/ladspa/ladspahelper.cpp b/src/plugins/Effect/ladspa/ladspahelper.cpp
index 338f16757..b844040d6 100644
--- a/src/plugins/Effect/ladspa/ladspahelper.cpp
+++ b/src/plugins/Effect/ladspa/ladspahelper.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2014 by Ilya Kotov *
+ * Copyright (C) 2009-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,11 +33,11 @@ LADSPAHelper::~LADSPAHelper()
void LADSPAHelper::applyEffect(Buffer *b)
{
- LADSPAHost::instance()->applyEffect((qint16 *)b->data, b->nbytes);
+ LADSPAHost::instance()->applyEffect(b->data, b->samples);
}
-void LADSPAHelper::configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format)
+void LADSPAHelper::configure(quint32 freq, ChannelMap map)
{
- LADSPAHost::instance()->configure(freq,map.count(),format);
- Effect::configure(freq, map, format);
+ LADSPAHost::instance()->configure(freq,map.count());
+ Effect::configure(freq, map);
}
diff --git a/src/plugins/Effect/ladspa/ladspahelper.h b/src/plugins/Effect/ladspa/ladspahelper.h
index 0ff749628..5f85b59ad 100644
--- a/src/plugins/Effect/ladspa/ladspahelper.h
+++ b/src/plugins/Effect/ladspa/ladspahelper.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2014 by Ilya Kotov *
+ * Copyright (C) 2009-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,7 +33,7 @@ public:
virtual ~LADSPAHelper();
void applyEffect(Buffer *b);
- void configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format);
+ void configure(quint32 freq, ChannelMap map);
};
#endif // LADSPAHELPER_H
diff --git a/src/plugins/Effect/ladspa/ladspahost.cpp b/src/plugins/Effect/ladspa/ladspahost.cpp
index 730088bff..ff4078f4b 100644
--- a/src/plugins/Effect/ladspa/ladspahost.cpp
+++ b/src/plugins/Effect/ladspa/ladspahost.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 2002-2003 Nick Lamb <njl195@zepler.org.uk> *
* Copyright (C) 2005 Giacomo Lozito <city_hunter@users.sf.net> *
- * Copyright (C) 2009-2012 by Ilya Kotov <forkotov02@hotmail.ru> *
+ * Copyright (C) 2009-2015 by Ilya Kotov <forkotov02@hotmail.ru> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -40,7 +40,6 @@ LADSPAHost *LADSPAHost::m_instance = 0;
LADSPAHost::LADSPAHost(QObject *parent) : QObject(parent)
{
m_chan = 0;
- m_prec = 0;
m_freq = 0;
m_instance = this;
findAllPlugins();
@@ -99,10 +98,9 @@ LADSPAHost::~LADSPAHost()
unload(effect);
}
-void LADSPAHost::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
+void LADSPAHost::configure(quint32 freq, int chan)
{
m_chan = chan;
- m_prec = AudioParameters::sampleSize(format);
m_freq = freq;
foreach(LADSPAEffect *e, m_effects)
{
@@ -239,48 +237,47 @@ void LADSPAHost::bootPlugin(LADSPAEffect *instance)
}
}
-int LADSPAHost::applyEffect(qint16 *d, int length)
+int LADSPAHost::applyEffect(float *data, size_t samples)
{
- qint16 *raw16 = d;
LADSPAEffect *instance;
- int k;
+ uint k;
if (m_effects.isEmpty())
- return length;
+ return samples;
if (m_chan == 1)
{
- for (k = 0; k < length >> 1; ++k)
- m_left[k] = (LADSPA_Data) raw16[k] / 32768.0f;
+ memcpy(m_left, data, samples * sizeof(float));
+
foreach(instance, m_effects)
{
if (instance->handle)
- instance->descriptor->run(instance->handle, length >> 1);
+ instance->descriptor->run(instance->handle, samples);
}
- for (k = 0; k < length >> 1; ++k)
- raw16[k] = qBound((int)(m_left[k] * 32768.0f), -32768, 32767);
+ for (k = 0; k < samples; ++k)
+ data[k] = qBound(-1.0f, m_left[k], 1.0f);
}
else
{
- for (k = 0; k < length >> 1; k += 2)
+ for (k = 0; k < samples; k += 2)
{
- m_left[k >> 1] = (LADSPA_Data) raw16[k] / 32768.0f;
- m_right[k >> 1] = (LADSPA_Data) raw16[k+1] / 32768.0f;
+ m_left[k >> 1] = data[k];
+ m_right[k >> 1] = data[k+1];
}
foreach(instance, m_effects)
{
if (instance->handle)
- instance->descriptor->run(instance->handle, length >> 2);
+ instance->descriptor->run(instance->handle, samples >> 1);
if (instance->handle2)
- instance->descriptor->run(instance->handle2, length >> 2);
+ instance->descriptor->run(instance->handle2, samples >> 1);
}
- for (k = 0; k < length >> 1; k += 2)
+ for (k = 0; k < samples; k+=2)
{
- raw16[k] = qBound((int)(m_left[k >> 1] * 32768.0f), -32768, 32767);
- raw16[k+1] = qBound((int)(m_right[k >> 1] * 32768.0f), -32768, 32767);
+ data[k] = qBound(-1.0f, m_left[k >> 1], 1.0f);
+ data[k+1] = qBound(-1.0f, m_right[k>> 1], 1.0f);
}
}
- return length;
+ return samples;
}
void LADSPAHost::portAssign(LADSPAEffect *instance)
diff --git a/src/plugins/Effect/ladspa/ladspahost.h b/src/plugins/Effect/ladspa/ladspahost.h
index b296fce38..df83c8083 100644
--- a/src/plugins/Effect/ladspa/ladspahost.h
+++ b/src/plugins/Effect/ladspa/ladspahost.h
@@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 2002,2003 Nick Lamb <njl195@zepler.org.uk> *
* Copyright (C) 2005 Giacomo Lozito <city_hunter@users.sf.net> *
- * Copyright (C) 2009 by Ilya Kotov <forkotov02@hotmail.ru> *
+ * Copyright (C) 2009-2015 by Ilya Kotov <forkotov02@hotmail.ru> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -24,6 +24,7 @@
#include <QMutex>
#include <QList>
#include <QObject>
+#include <stddef.h>
#include <qmmp/qmmp.h>
#include "ladspa.h"
@@ -84,8 +85,8 @@ public:
virtual ~LADSPAHost();
- int applyEffect(qint16 *d, int length);
- void configure(quint32 freq, int chan, Qmmp::AudioFormat format);
+ int applyEffect(float *data, size_t samples);
+ void configure(quint32 freq, int chan);
QList <LADSPAPlugin *> plugins();
QList <LADSPAEffect *> effects();
LADSPAEffect *addPlugin(LADSPAPlugin * plugin);
@@ -106,7 +107,7 @@ private:
LADSPA_Data m_left[MAX_SAMPLES], m_right[MAX_SAMPLES], m_trash[MAX_SAMPLES];
static LADSPAHost *m_instance;
- int m_chan, m_prec;
+ int m_chan;
quint32 m_freq;
};
diff --git a/src/plugins/Effect/stereo/stereoplugin.cpp b/src/plugins/Effect/stereo/stereoplugin.cpp
index 20c27de09..dcfff2a75 100644
--- a/src/plugins/Effect/stereo/stereoplugin.cpp
+++ b/src/plugins/Effect/stereo/stereoplugin.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 1999 by Johan Levin *
* *
- * Copyright (C) 2011-2014 by Ilya Kotov *
+ * Copyright (C) 2011-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,7 +31,6 @@ StereoPlugin *StereoPlugin::m_instance = 0;
StereoPlugin::StereoPlugin() : Effect()
{
m_instance = this;
- m_format = Qmmp::PCM_S16LE;
m_avg = 0;
m_ldiff = 0;
m_rdiff = 0;
@@ -53,44 +52,27 @@ void StereoPlugin::applyEffect(Buffer *b)
return;
m_mutex.lock();
- if(m_format == Qmmp::PCM_S16LE)
- {
- short *data = (short *)b->data;
- for (uint i = 0; i < (b->nbytes >> 1); i += 2)
- {
- m_avg = (data[i] + data[i + 1]) / 2;
- m_ldiff = data[i] - m_avg;
- m_rdiff = data[i + 1] - m_avg;
+ float *data = b->data;
- m_tmp = m_avg + m_ldiff * m_mul;
- data[i] = qBound(-32768.0, m_tmp, 32767.0);
- m_tmp = m_avg + m_rdiff * m_mul;
- data[i + 1] = qBound(-32768.0, m_tmp, 32767.0);
- }
- }
- else if(m_format == Qmmp::PCM_S24LE || m_format == Qmmp::PCM_S32LE)
+ for (uint i = 0; i < b->samples; i += 2)
{
- int *data = (int *)b->data;
- for (uint i = 0; i < (b->nbytes >> 2); i += 2)
- {
- m_avg = (data[i] + data[i + 1]) / 2;
- m_ldiff = data[i] - m_avg;
- m_rdiff = data[i + 1] - m_avg;
+ m_avg = (data[i] + data[i + 1]) / 2;
+ m_ldiff = data[i] - m_avg;
+ m_rdiff = data[i + 1] - m_avg;
- m_tmp = m_avg + m_ldiff * m_mul;
- data[i] = m_tmp;
- m_tmp = m_avg + m_rdiff * m_mul;
- data[i + 1] = m_tmp;
- }
+ m_tmp = m_avg + m_ldiff * m_mul;
+ data[i] = qBound(-1.0, m_tmp, 1.0);
+ m_tmp = m_avg + m_rdiff * m_mul;
+ data[i + 1] = qBound(-1.0, m_tmp, 1.0);
}
+
m_mutex.unlock();
}
-void StereoPlugin::configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format)
+void StereoPlugin::configure(quint32 freq, ChannelMap map)
{
m_chan = map.count();
- m_format = format;
- Effect::configure(freq, map, format);
+ Effect::configure(freq, map);
}
void StereoPlugin::setIntensity(double level)
diff --git a/src/plugins/Effect/stereo/stereoplugin.h b/src/plugins/Effect/stereo/stereoplugin.h
index a9901048b..19f18a148 100644
--- a/src/plugins/Effect/stereo/stereoplugin.h
+++ b/src/plugins/Effect/stereo/stereoplugin.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011-2014 by Ilya Kotov *
+ * Copyright (C) 2011-2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -34,7 +34,7 @@ public:
virtual ~StereoPlugin();
void applyEffect(Buffer *b);
- void configure(quint32 freq, ChannelMap map, Qmmp::AudioFormat format);
+ void configure(quint32 freq, ChannelMap map);
void setIntensity(double level);
static StereoPlugin* instance();
@@ -42,7 +42,6 @@ private:
int m_chan;
QMutex m_mutex;
double m_avg, m_ldiff, m_rdiff, m_tmp, m_mul;
- int m_format;
static StereoPlugin *m_instance;
};