Mercurial > hg > easaier-soundaccess
comparison sv/transform/PluginTransform.cpp @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "PluginTransform.h" | |
17 | |
18 #include "vamp-sdk/PluginHostAdapter.h" | |
19 | |
20 PluginTransform::PluginTransform(Model *inputModel, | |
21 const ExecutionContext &context) : | |
22 Transform(inputModel), | |
23 m_context(context) | |
24 { | |
25 } | |
26 | |
27 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) : | |
28 channel(_c), | |
29 domain(Vamp::Plugin::TimeDomain), | |
30 stepSize(_bs ? _bs : 1024), | |
31 blockSize(_bs ? _bs : 1024), | |
32 windowType(HanningWindow) | |
33 { | |
34 } | |
35 | |
36 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss, | |
37 size_t _bs, WindowType _wt) : | |
38 channel(_c), | |
39 domain(Vamp::Plugin::FrequencyDomain), | |
40 stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)), | |
41 blockSize(_bs ? _bs : 1024), | |
42 windowType(_wt) | |
43 { | |
44 } | |
45 | |
46 PluginTransform::ExecutionContext::ExecutionContext(int _c, | |
47 const Vamp::PluginBase *_plugin) : | |
48 channel(_c), | |
49 domain(Vamp::Plugin::TimeDomain), | |
50 stepSize(0), | |
51 blockSize(0), | |
52 windowType(HanningWindow) | |
53 { | |
54 makeConsistentWithPlugin(_plugin); | |
55 } | |
56 | |
57 bool | |
58 PluginTransform::ExecutionContext::operator==(const ExecutionContext &c) | |
59 { | |
60 return (c.channel == channel && | |
61 c.domain == domain && | |
62 c.stepSize == stepSize && | |
63 c.blockSize == blockSize && | |
64 c.windowType == windowType); | |
65 } | |
66 | |
67 void | |
68 PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin) | |
69 { | |
70 const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin); | |
71 if (!vp) { | |
72 vp = dynamic_cast<const Vamp::PluginHostAdapter *>(_plugin); //!!! why? | |
73 } | |
74 | |
75 if (!vp) { | |
76 domain = Vamp::Plugin::TimeDomain; | |
77 if (!stepSize) { | |
78 if (!blockSize) blockSize = 1024; | |
79 stepSize = blockSize; | |
80 } else { | |
81 if (!blockSize) blockSize = stepSize; | |
82 } | |
83 } else { | |
84 domain = vp->getInputDomain(); | |
85 if (!stepSize) stepSize = vp->getPreferredStepSize(); | |
86 if (!blockSize) blockSize = vp->getPreferredBlockSize(); | |
87 if (!blockSize) blockSize = 1024; | |
88 if (!stepSize) { | |
89 if (domain == Vamp::Plugin::FrequencyDomain) { | |
90 stepSize = blockSize/2; | |
91 } else { | |
92 stepSize = blockSize; | |
93 } | |
94 } | |
95 } | |
96 } | |
97 | |
98 |