aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-11-13 21:37:19 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-11-13 21:37:19 +0000
commitcd326acf90ee9c34b8d3609d6ecabbdc8b0cf6fb (patch)
tree9f43024cda37cf4b9da72ea23fe35807d032ca71 /src
parent7f9f355b82009f56ff7bded0093a2d1712e2f950 (diff)
downloadqmmp-cd326acf90ee9c34b8d3609d6ecabbdc8b0cf6fb.tar.gz
qmmp-cd326acf90ee9c34b8d3609d6ecabbdc8b0cf6fb.tar.bz2
qmmp-cd326acf90ee9c34b8d3609d6ecabbdc8b0cf6fb.zip
added mono to stereo converter
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8424 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Effect/Effect.pro2
-rw-r--r--src/plugins/Effect/monotostereo/effectmonotostereofactory.cpp56
-rw-r--r--src/plugins/Effect/monotostereo/effectmonotostereofactory.h45
-rw-r--r--src/plugins/Effect/monotostereo/monotostereo.pro16
-rw-r--r--src/plugins/Effect/monotostereo/monotostereoplugin.cpp79
-rw-r--r--src/plugins/Effect/monotostereo/monotostereoplugin.h46
6 files changed, 243 insertions, 1 deletions
diff --git a/src/plugins/Effect/Effect.pro b/src/plugins/Effect/Effect.pro
index 5a1cc69f7..d24a4323f 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 monotostereo
contains(CONFIG, BS2B_PLUGIN):SUBDIRS += bs2b
contains(CONFIG, SOXR_PLUGIN):SUBDIRS += soxr
diff --git a/src/plugins/Effect/monotostereo/effectmonotostereofactory.cpp b/src/plugins/Effect/monotostereo/effectmonotostereofactory.cpp
new file mode 100644
index 000000000..6bae99ddd
--- /dev/null
+++ b/src/plugins/Effect/monotostereo/effectmonotostereofactory.cpp
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Ilya Kotov *
+ * forkotov02@ya.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <QMessageBox>
+#include <qmmp/qmmp.h>
+#include "effectmonotostereofactory.h"
+#include "monotostereoplugin.h"
+
+const EffectProperties EffectMonoToStereoFactory::properties() const
+{
+ EffectProperties properties;
+ properties.name = tr("Mono to Stereo Converter Plugin");
+ properties.shortName = "monotostereo";
+ properties.hasSettings = false;
+ properties.hasAbout = true;
+ return properties;
+}
+
+Effect *EffectMonoToStereoFactory::create()
+{
+ return new MonoToStereoPlugin();
+}
+
+void EffectMonoToStereoFactory::showSettings(QWidget *parent)
+{
+ Q_UNUSED(parent);
+}
+
+void EffectMonoToStereoFactory::showAbout(QWidget *parent)
+{
+ QMessageBox::about(parent, tr("About Mono to Stereo Converter Plugin"),
+ tr("Qmmp Mono to Stereo Converter Plugin")+"\n"+
+ tr("Written by: Ilya Kotov <forkotov02@ya.ru>"));
+}
+
+QString EffectMonoToStereoFactory::translation() const
+{
+ return QLatin1String(":/monotostereo_plugin_");
+}
diff --git a/src/plugins/Effect/monotostereo/effectmonotostereofactory.h b/src/plugins/Effect/monotostereo/effectmonotostereofactory.h
new file mode 100644
index 000000000..ee1ddc9f1
--- /dev/null
+++ b/src/plugins/Effect/monotostereo/effectmonotostereofactory.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Ilya Kotov *
+ * forkotov02@ya.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef EFFECTMONOTOSTEREOFACTORY_H
+#define EFFECTMONOTOSTEREOFACTORY_H
+
+#include <QObject>
+#include <qmmp/effectfactory.h>
+#include <qmmp/effect.h>
+
+/**
+ @author Ilya Kotov <forkotov02@ya.ru>
+*/
+class EffectMonoToStereoFactory : public QObject, public EffectFactory
+{
+Q_OBJECT
+Q_PLUGIN_METADATA(IID "org.qmmp.qmmp.EffectFactoryInterface.1.0")
+Q_INTERFACES(EffectFactory)
+
+public:
+ const EffectProperties properties() const;
+ Effect *create();
+ void showSettings(QWidget *parent);
+ void showAbout(QWidget *parent);
+ QString translation() const;
+};
+
+
+#endif
diff --git a/src/plugins/Effect/monotostereo/monotostereo.pro b/src/plugins/Effect/monotostereo/monotostereo.pro
new file mode 100644
index 000000000..fb5b69f6d
--- /dev/null
+++ b/src/plugins/Effect/monotostereo/monotostereo.pro
@@ -0,0 +1,16 @@
+include(../../plugins.pri)
+
+TARGET = $$PLUGINS_PREFIX/Effect/monotostereo
+
+HEADERS += monotostereoplugin.h \
+ effectmonotostereofactory.h
+
+SOURCES += monotostereoplugin.cpp \
+ effectmonotostereofactory.cpp
+
+#RESOURCES = translations/translations.qrc
+
+unix {
+ target.path = $$PLUGIN_DIR/Effect
+ INSTALLS += target
+}
diff --git a/src/plugins/Effect/monotostereo/monotostereoplugin.cpp b/src/plugins/Effect/monotostereo/monotostereoplugin.cpp
new file mode 100644
index 000000000..b043d3f65
--- /dev/null
+++ b/src/plugins/Effect/monotostereo/monotostereoplugin.cpp
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Ilya Kotov *
+ * forkotov02@ya.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <stdlib.h>
+#include <qmmp/qmmp.h>
+#include "monotostereoplugin.h"
+
+MonoToStereoPlugin::MonoToStereoPlugin() : Effect()
+{
+ m_tmp = 0;
+ m_size = 0;
+ m_enabled = false;
+}
+
+MonoToStereoPlugin::~MonoToStereoPlugin()
+{
+ if(m_tmp)
+ {
+ delete[] m_tmp;
+ m_tmp = 0;
+ }
+}
+
+void MonoToStereoPlugin::applyEffect(Buffer *b)
+{
+ if(m_enabled)
+ {
+ if(m_size < b->samples)
+ {
+ if(m_tmp)
+ delete [] m_tmp;
+ m_tmp = new float[b->samples];
+ }
+ memcpy(m_tmp, b->data, b->samples * sizeof(float));
+
+ b->samples *= 2;
+
+ if(b->samples > b->size)
+ {
+ delete [] b->data;
+ b->size = b->samples;
+ b->data = new float[b->size];
+ }
+
+ for(size_t i = 0; i < b->samples; ++i)
+ b->data[i] = m_tmp[i >> 1];
+ }
+}
+
+void MonoToStereoPlugin::configure(quint32 freq, ChannelMap map)
+{
+ if(map.count() == 1)
+ {
+ m_enabled = true;
+ Effect::configure(freq, ChannelMap(2));
+ }
+ else
+ {
+ m_enabled = false;
+ Effect::configure(freq, map);
+ }
+}
diff --git a/src/plugins/Effect/monotostereo/monotostereoplugin.h b/src/plugins/Effect/monotostereo/monotostereoplugin.h
new file mode 100644
index 000000000..a3a92f2d1
--- /dev/null
+++ b/src/plugins/Effect/monotostereo/monotostereoplugin.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Ilya Kotov *
+ * forkotov02@ya.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef MONOTOSTEREOPLUGIN_H
+#define MONOTOSTEREOPLUGIN_H
+
+#include <QMutex>
+#include <qmmp/effect.h>
+
+/**
+ @author Ilya Kotov <forkotov02@ya.ru>
+*/
+class MonoToStereoPlugin : public Effect
+{
+public:
+ MonoToStereoPlugin();
+
+ virtual ~MonoToStereoPlugin();
+
+ void applyEffect(Buffer *b);
+ void configure(quint32 freq, ChannelMap map);
+
+private:
+ bool m_enabled;
+ float *m_tmp;
+ size_t m_size; //in samples
+
+};
+
+#endif