annotate transform/PluginTransform.cpp @ 165:33280c031d19

* Add a colour database, and Add New Colour function to the colour combo in property box. The colour property is only correctly handled in the waveform layer so far. * Add en_GB translation, to translate those annoying Color texts in the Qt colour picker dialog.
author Chris Cannam
date Wed, 11 Jul 2007 17:21:37 +0000
parents bedc7517b6e8
children a65a01870d8c
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@77 7 This file copyright 2006 QMUL.
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@28 18 #include "vamp-sdk/PluginHostAdapter.h"
Chris@28 19
Chris@27 20 PluginTransform::PluginTransform(Model *inputModel,
Chris@27 21 const ExecutionContext &context) :
Chris@27 22 Transform(inputModel),
Chris@27 23 m_context(context)
Chris@27 24 {
Chris@27 25 }
Chris@27 26
Chris@27 27 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) :
Chris@27 28 channel(_c),
Chris@27 29 domain(Vamp::Plugin::TimeDomain),
Chris@27 30 stepSize(_bs ? _bs : 1024),
Chris@27 31 blockSize(_bs ? _bs : 1024),
Chris@27 32 windowType(HanningWindow)
Chris@27 33 {
Chris@27 34 }
Chris@27 35
Chris@27 36 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss,
Chris@27 37 size_t _bs, WindowType _wt) :
Chris@27 38 channel(_c),
Chris@27 39 domain(Vamp::Plugin::FrequencyDomain),
Chris@27 40 stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)),
Chris@27 41 blockSize(_bs ? _bs : 1024),
Chris@27 42 windowType(_wt)
Chris@27 43 {
Chris@27 44 }
Chris@27 45
Chris@27 46 PluginTransform::ExecutionContext::ExecutionContext(int _c,
Chris@27 47 const Vamp::PluginBase *_plugin) :
Chris@27 48 channel(_c),
Chris@27 49 domain(Vamp::Plugin::TimeDomain),
Chris@27 50 stepSize(0),
Chris@27 51 blockSize(0),
Chris@27 52 windowType(HanningWindow)
Chris@27 53 {
Chris@27 54 makeConsistentWithPlugin(_plugin);
Chris@27 55 }
Chris@27 56
Chris@27 57 bool
Chris@27 58 PluginTransform::ExecutionContext::operator==(const ExecutionContext &c)
Chris@27 59 {
Chris@27 60 return (c.channel == channel &&
Chris@27 61 c.domain == domain &&
Chris@27 62 c.stepSize == stepSize &&
Chris@27 63 c.blockSize == blockSize &&
Chris@27 64 c.windowType == windowType);
Chris@27 65 }
Chris@27 66
Chris@27 67 void
Chris@27 68 PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin)
Chris@27 69 {
Chris@27 70 const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin);
Chris@28 71 if (!vp) {
Chris@28 72 vp = dynamic_cast<const Vamp::PluginHostAdapter *>(_plugin); //!!! why?
Chris@28 73 }
Chris@27 74
Chris@27 75 if (!vp) {
Chris@27 76 domain = Vamp::Plugin::TimeDomain;
Chris@27 77 if (!stepSize) {
Chris@27 78 if (!blockSize) blockSize = 1024;
Chris@27 79 stepSize = blockSize;
Chris@27 80 } else {
Chris@27 81 if (!blockSize) blockSize = stepSize;
Chris@27 82 }
Chris@27 83 } else {
Chris@27 84 domain = vp->getInputDomain();
Chris@27 85 if (!stepSize) stepSize = vp->getPreferredStepSize();
Chris@27 86 if (!blockSize) blockSize = vp->getPreferredBlockSize();
Chris@27 87 if (!blockSize) blockSize = 1024;
Chris@27 88 if (!stepSize) {
Chris@27 89 if (domain == Vamp::Plugin::FrequencyDomain) {
Chris@27 90 stepSize = blockSize/2;
Chris@27 91 } else {
Chris@27 92 stepSize = blockSize;
Chris@27 93 }
Chris@27 94 }
Chris@27 95 }
Chris@27 96 }
Chris@27 97
Chris@27 98