Mercurial > hg > sonic-visualiser
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:d88d117e0c34 | 27:61259228d029 |
---|---|
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 Chris Cannam. | |
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 PluginTransform::PluginTransform(Model *inputModel, | |
19 const ExecutionContext &context) : | |
20 Transform(inputModel), | |
21 m_context(context) | |
22 { | |
23 } | |
24 | |
25 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) : | |
26 channel(_c), | |
27 domain(Vamp::Plugin::TimeDomain), | |
28 stepSize(_bs ? _bs : 1024), | |
29 blockSize(_bs ? _bs : 1024), | |
30 windowType(HanningWindow) | |
31 { | |
32 } | |
33 | |
34 PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss, | |
35 size_t _bs, WindowType _wt) : | |
36 channel(_c), | |
37 domain(Vamp::Plugin::FrequencyDomain), | |
38 stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)), | |
39 blockSize(_bs ? _bs : 1024), | |
40 windowType(_wt) | |
41 { | |
42 } | |
43 | |
44 PluginTransform::ExecutionContext::ExecutionContext(int _c, | |
45 const Vamp::PluginBase *_plugin) : | |
46 channel(_c), | |
47 domain(Vamp::Plugin::TimeDomain), | |
48 stepSize(0), | |
49 blockSize(0), | |
50 windowType(HanningWindow) | |
51 { | |
52 makeConsistentWithPlugin(_plugin); | |
53 } | |
54 | |
55 bool | |
56 PluginTransform::ExecutionContext::operator==(const ExecutionContext &c) | |
57 { | |
58 return (c.channel == channel && | |
59 c.domain == domain && | |
60 c.stepSize == stepSize && | |
61 c.blockSize == blockSize && | |
62 c.windowType == windowType); | |
63 } | |
64 | |
65 void | |
66 PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin) | |
67 { | |
68 const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin); | |
69 | |
70 if (!vp) { | |
71 domain = Vamp::Plugin::TimeDomain; | |
72 if (!stepSize) { | |
73 if (!blockSize) blockSize = 1024; | |
74 stepSize = blockSize; | |
75 } else { | |
76 if (!blockSize) blockSize = stepSize; | |
77 } | |
78 } else { | |
79 domain = vp->getInputDomain(); | |
80 if (!stepSize) stepSize = vp->getPreferredStepSize(); | |
81 if (!blockSize) blockSize = vp->getPreferredBlockSize(); | |
82 if (!blockSize) blockSize = 1024; | |
83 if (!stepSize) { | |
84 if (domain == Vamp::Plugin::FrequencyDomain) { | |
85 stepSize = blockSize/2; | |
86 } else { | |
87 stepSize = blockSize; | |
88 } | |
89 } | |
90 } | |
91 } | |
92 | |
93 |