diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-12-07 19:17:57 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-12-07 19:17:57 +0000 |
| commit | f3ebf1f3ec5ac77633db0509e12f87abb066c334 (patch) | |
| tree | 4c8e5be9ed3b2d01071dd1fe7137eeb4ff0eda56 /src/plugins/Effect/ladspa/ladspahost.cpp | |
| parent | 1128dce7d78ce44f6157259efc73b38ae7005133 (diff) | |
| download | qmmp-f3ebf1f3ec5ac77633db0509e12f87abb066c334.tar.gz qmmp-f3ebf1f3ec5ac77633db0509e12f87abb066c334.tar.bz2 qmmp-f3ebf1f3ec5ac77633db0509e12f87abb066c334.zip | |
enabled ladspa plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1427 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Effect/ladspa/ladspahost.cpp')
| -rw-r--r-- | src/plugins/Effect/ladspa/ladspahost.cpp | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/plugins/Effect/ladspa/ladspahost.cpp b/src/plugins/Effect/ladspa/ladspahost.cpp index a204f2c2b..d9eef5281 100644 --- a/src/plugins/Effect/ladspa/ladspahost.cpp +++ b/src/plugins/Effect/ladspa/ladspahost.cpp @@ -1,6 +1,7 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * - * <forkotov02@hotmail.ru> * + * 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> * * * * 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 * @@ -37,8 +38,11 @@ LADSPAHost *LADSPAHost::m_instance = 0; -LADSPAHost::LADSPAHost() : Effect() +LADSPAHost::LADSPAHost(QObject *parent) : QObject(parent) { + m_chan = 0; + m_prec = 0; + m_freq = 0; m_instance = this; findAllPlugins(); } @@ -52,16 +56,30 @@ LADSPAHost::~LADSPAHost() } } -ulong LADSPAHost::process(char *in_data, const ulong size, char **out_data) -{ - applyEffect((qint16 *) in_data, size); - memcpy(*out_data, in_data, size); - return size; -} - void LADSPAHost::configure(quint32 freq, int chan, int res) { - Effect::configure(freq, chan, res); + m_chan = chan; + m_prec = res; + m_freq = freq; + foreach(LADSPAEffect *e, m_effects) + { + const LADSPA_Descriptor *descriptor = e->descriptor; + if (e->handle) + { + if (descriptor->deactivate) + descriptor->deactivate(e->handle); + descriptor->cleanup(e->handle); + e->handle = 0; + } + if (e->handle2) + { + if (descriptor->deactivate) + descriptor->deactivate(e->handle2); + descriptor->cleanup(e->handle2); + e->handle2 = 0; + } + bootPlugin(e); + } } LADSPAHost* LADSPAHost::instance() @@ -79,7 +97,7 @@ QList <LADSPAEffect *> LADSPAHost::runningPlugins() return m_effects; } -/*!!!!*/ +/*Based on xmms_ladspa */ void LADSPAHost::findAllPlugins() { while(!m_plugins.isEmpty()) /* empty list */ @@ -159,11 +177,11 @@ void LADSPAHost::bootPlugin(LADSPAEffect *instance) { const LADSPA_Descriptor *descriptor = instance->descriptor; - instance->handle = descriptor->instantiate(descriptor, (int)sampleRate()); - if (channels() > 1 && !instance->stereo) + instance->handle = descriptor->instantiate(descriptor, m_freq); + if (m_chan > 1 && !instance->stereo) { /* Create an additional instance */ - instance->handle2 = descriptor->instantiate(descriptor, (int)sampleRate()); + instance->handle2 = descriptor->instantiate(descriptor, m_freq); } portAssign(instance); @@ -181,12 +199,11 @@ int LADSPAHost::applyEffect(qint16 *d, int length) qint16 *raw16 = d; LADSPAEffect *instance; int k; - int nch = channels(); if (m_effects.isEmpty()) return length; - if (nch == 1) + if (m_chan == 1) { for (k = 0; k < length / 2; ++k) m_left[k] = ((LADSPA_Data) raw16[k]) * (1.0f / 32768.0f); @@ -362,7 +379,7 @@ LADSPAEffect *LADSPAHost::addPlugin(LADSPAPlugin *plugin) if (!(instance = load(plugin->fileName, plugin->id))) return 0; instance->stereo = plugin->stereo; - if (channels() && sampleRate()) + if (m_chan && m_freq) bootPlugin(instance); initialize(instance); m_effects.append(instance); @@ -396,7 +413,7 @@ void LADSPAHost::initialize(LADSPAEffect *instance) } if (LADSPA_IS_HINT_SAMPLE_RATE(hints[k].HintDescriptor)) - fact = sampleRate(); + fact = m_freq; else fact = 1.0f; |
