Chris@27: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@27: Chris@27: /* Chris@27: Sonic Visualiser Chris@27: An audio file viewer and annotation editor. Chris@27: Centre for Digital Music, Queen Mary, University of London. Chris@77: This file copyright 2006 QMUL. Chris@27: Chris@27: This program is free software; you can redistribute it and/or Chris@27: modify it under the terms of the GNU General Public License as Chris@27: published by the Free Software Foundation; either version 2 of the Chris@27: License, or (at your option) any later version. See the file Chris@27: COPYING included with this distribution for more information. Chris@27: */ Chris@27: Chris@27: #include "PluginTransform.h" Chris@27: Chris@28: #include "vamp-sdk/PluginHostAdapter.h" Chris@28: Chris@27: PluginTransform::PluginTransform(Model *inputModel, Chris@27: const ExecutionContext &context) : Chris@27: Transform(inputModel), Chris@27: m_context(context) Chris@27: { Chris@27: } Chris@27: Chris@27: PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) : Chris@27: channel(_c), Chris@27: domain(Vamp::Plugin::TimeDomain), Chris@27: stepSize(_bs ? _bs : 1024), Chris@27: blockSize(_bs ? _bs : 1024), Chris@27: windowType(HanningWindow) Chris@27: { Chris@27: } Chris@27: Chris@27: PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss, Chris@27: size_t _bs, WindowType _wt) : Chris@27: channel(_c), Chris@27: domain(Vamp::Plugin::FrequencyDomain), Chris@27: stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)), Chris@27: blockSize(_bs ? _bs : 1024), Chris@27: windowType(_wt) Chris@27: { Chris@27: } Chris@27: Chris@27: PluginTransform::ExecutionContext::ExecutionContext(int _c, Chris@27: const Vamp::PluginBase *_plugin) : Chris@27: channel(_c), Chris@27: domain(Vamp::Plugin::TimeDomain), Chris@27: stepSize(0), Chris@27: blockSize(0), Chris@27: windowType(HanningWindow) Chris@27: { Chris@27: makeConsistentWithPlugin(_plugin); Chris@27: } Chris@27: Chris@27: bool Chris@27: PluginTransform::ExecutionContext::operator==(const ExecutionContext &c) Chris@27: { Chris@27: return (c.channel == channel && Chris@27: c.domain == domain && Chris@27: c.stepSize == stepSize && Chris@27: c.blockSize == blockSize && Chris@27: c.windowType == windowType); Chris@27: } Chris@27: Chris@27: void Chris@27: PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin) Chris@27: { Chris@27: const Vamp::Plugin *vp = dynamic_cast(_plugin); Chris@28: if (!vp) { Chris@28: vp = dynamic_cast(_plugin); //!!! why? Chris@28: } Chris@27: Chris@27: if (!vp) { Chris@27: domain = Vamp::Plugin::TimeDomain; Chris@27: if (!stepSize) { Chris@27: if (!blockSize) blockSize = 1024; Chris@27: stepSize = blockSize; Chris@27: } else { Chris@27: if (!blockSize) blockSize = stepSize; Chris@27: } Chris@27: } else { Chris@27: domain = vp->getInputDomain(); Chris@27: if (!stepSize) stepSize = vp->getPreferredStepSize(); Chris@27: if (!blockSize) blockSize = vp->getPreferredBlockSize(); Chris@27: if (!blockSize) blockSize = 1024; Chris@27: if (!stepSize) { Chris@27: if (domain == Vamp::Plugin::FrequencyDomain) { Chris@27: stepSize = blockSize/2; Chris@27: } else { Chris@27: stepSize = blockSize; Chris@27: } Chris@27: } Chris@27: } Chris@27: } Chris@27: Chris@27: