annotate transform/PluginTransform.cpp @ 27:61259228d029

* More to do with passing around step/blocksize etc from plugin dialog to plugins. Still some puzzling unresolved details.
author Chris Cannam
date Tue, 19 Sep 2006 14:37:06 +0000
parents
children b5f55ea61bb8
rev   line source
Chris@27 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@27 2
Chris@27 3 /*
Chris@27 4 Sonic Visualiser
Chris@27 5 An audio file viewer and annotation editor.
Chris@27 6 Centre for Digital Music, Queen Mary, University of London.
Chris@27 7 This file copyright 2006 Chris Cannam.
Chris@27 8
Chris@27 9 This program is free software; you can redistribute it and/or
Chris@27 10 modify it under the terms of the GNU General Public License as
Chris@27 11 published by the Free Software Foundation; either version 2 of the
Chris@27 12 License, or (at your option) any later version. See the file
Chris@27 13 COPYING included with this distribution for more information.
Chris@27 14 */
Chris@27 15
Chris@27 16 #include "PluginTransform.h"
Chris@27 17
Chris@27 18 PluginTransform::PluginTransform(Model *inputModel,
Chris@27 19 const ExecutionContext &context) :
Chris@27 20 Transform(inputModel),
Chris@27 21 m_context(context)
Chris@27 22 {
Chris@27 23 }
Chris@27 24
Chris@27 25 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) :
Chris@27 26 channel(_c),
Chris@27 27 domain(Vamp::Plugin::TimeDomain),
Chris@27 28 stepSize(_bs ? _bs : 1024),
Chris@27 29 blockSize(_bs ? _bs : 1024),
Chris@27 30 windowType(HanningWindow)
Chris@27 31 {
Chris@27 32 }
Chris@27 33
Chris@27 34 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss,
Chris@27 35 size_t _bs, WindowType _wt) :
Chris@27 36 channel(_c),
Chris@27 37 domain(Vamp::Plugin::FrequencyDomain),
Chris@27 38 stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)),
Chris@27 39 blockSize(_bs ? _bs : 1024),
Chris@27 40 windowType(_wt)
Chris@27 41 {
Chris@27 42 }
Chris@27 43
Chris@27 44 PluginTransform::ExecutionContext::ExecutionContext(int _c,
Chris@27 45 const Vamp::PluginBase *_plugin) :
Chris@27 46 channel(_c),
Chris@27 47 domain(Vamp::Plugin::TimeDomain),
Chris@27 48 stepSize(0),
Chris@27 49 blockSize(0),
Chris@27 50 windowType(HanningWindow)
Chris@27 51 {
Chris@27 52 makeConsistentWithPlugin(_plugin);
Chris@27 53 }
Chris@27 54
Chris@27 55 bool
Chris@27 56 PluginTransform::ExecutionContext::operator==(const ExecutionContext &c)
Chris@27 57 {
Chris@27 58 return (c.channel == channel &&
Chris@27 59 c.domain == domain &&
Chris@27 60 c.stepSize == stepSize &&
Chris@27 61 c.blockSize == blockSize &&
Chris@27 62 c.windowType == windowType);
Chris@27 63 }
Chris@27 64
Chris@27 65 void
Chris@27 66 PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin)
Chris@27 67 {
Chris@27 68 const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin);
Chris@27 69
Chris@27 70 if (!vp) {
Chris@27 71 domain = Vamp::Plugin::TimeDomain;
Chris@27 72 if (!stepSize) {
Chris@27 73 if (!blockSize) blockSize = 1024;
Chris@27 74 stepSize = blockSize;
Chris@27 75 } else {
Chris@27 76 if (!blockSize) blockSize = stepSize;
Chris@27 77 }
Chris@27 78 } else {
Chris@27 79 domain = vp->getInputDomain();
Chris@27 80 if (!stepSize) stepSize = vp->getPreferredStepSize();
Chris@27 81 if (!blockSize) blockSize = vp->getPreferredBlockSize();
Chris@27 82 if (!blockSize) blockSize = 1024;
Chris@27 83 if (!stepSize) {
Chris@27 84 if (domain == Vamp::Plugin::FrequencyDomain) {
Chris@27 85 stepSize = blockSize/2;
Chris@27 86 } else {
Chris@27 87 stepSize = blockSize;
Chris@27 88 }
Chris@27 89 }
Chris@27 90 }
Chris@27 91 }
Chris@27 92
Chris@27 93