|
31 | 31 |
|
32 | 32 | struct SpaOscModelFactoryVisitor : public spa::audio::visitor |
33 | 33 | { |
34 | | - class SpaInstrument *inst_ref; |
35 | | - const QString *dest; |
36 | | - AutomatableModel *res = nullptr; |
| 34 | + class SpaInstrument *m_instRef; |
| 35 | + const QString *m_dest; |
| 36 | + AutomatableModel *m_res = nullptr; |
37 | 37 |
|
38 | 38 | template <class ModelType, class T> void make(T min, T max, T val) |
39 | 39 | { |
40 | | - res = new ModelType(inst_ref, *dest, min, max, val); |
| 40 | + m_res = new ModelType(m_instRef, *m_dest, min, max, val); |
41 | 41 | } |
42 | 42 |
|
43 | | - template <class T> using c_in = spa::audio::control_in<T>; |
44 | | - virtual void visit(c_in<float> &in) |
| 43 | + template <class T> using CtlIn = spa::audio::control_in<T>; |
| 44 | + virtual void visit(CtlIn<float> &in) |
45 | 45 | { |
46 | 46 | make<FloatOscModel>(in.min, in.max, in.def); |
47 | 47 | } |
48 | | - virtual void visit(c_in<double> &in) |
| 48 | + virtual void visit(CtlIn<double> &in) |
49 | 49 | { |
50 | 50 | make<FloatOscModel>(in.min, in.max, in.def); |
51 | 51 | } |
52 | | - virtual void visit(c_in<int> &in) |
| 52 | + virtual void visit(CtlIn<int> &in) |
53 | 53 | { |
54 | 54 | make<IntOscModel>(in.min, in.max, in.def); |
55 | 55 | } |
56 | | - virtual void visit(c_in<bool> &in) |
| 56 | + virtual void visit(CtlIn<bool> &in) |
57 | 57 | { |
58 | | - res = new BoolOscModel(inst_ref, *dest, in.def); |
| 58 | + m_res = new BoolOscModel(m_instRef, *m_dest, in.def); |
59 | 59 | } |
60 | 60 | }; |
61 | 61 |
|
62 | 62 | SpaOscModelFactory::SpaOscModelFactory( |
63 | | - SpaInstrument *inst_ref, const QString &dest) |
| 63 | + SpaInstrument *instRef, const QString &dest) |
64 | 64 | { |
65 | 65 | SpaOscModelFactoryVisitor vis; |
66 | | - vis.inst_ref = inst_ref; |
67 | | - vis.dest = &dest; |
68 | | - spa::port_ref_base &base = inst_ref->plugin->port(dest.toUtf8().data()); |
| 66 | + vis.m_instRef = instRef; |
| 67 | + vis.m_dest = &dest; |
| 68 | + spa::port_ref_base &base = instRef->m_plugin->port(dest.toUtf8().data()); |
69 | 69 | base.accept(vis); |
70 | | - res = vis.res; |
| 70 | + m_res = vis.m_res; |
71 | 71 | } |
72 | 72 |
|
73 | 73 | void BoolOscModel::sendOsc() |
74 | 74 | { |
75 | | - inst_ref->writeOsc(dest.data(), value() ? "T" : "F"); |
| 75 | + m_instRef->writeOsc(m_dest.data(), value() ? "T" : "F"); |
| 76 | +} |
| 77 | +void IntOscModel::sendOsc() |
| 78 | +{ |
| 79 | + m_instRef->writeOsc(m_dest.data(), "i", value()); |
| 80 | +} |
| 81 | +void FloatOscModel::sendOsc() |
| 82 | +{ |
| 83 | + m_instRef->writeOsc(m_dest.data(), "f", value()); |
76 | 84 | } |
77 | | -void IntOscModel::sendOsc() { inst_ref->writeOsc(dest.data(), "i", value()); } |
78 | | -void FloatOscModel::sendOsc() { inst_ref->writeOsc(dest.data(), "f", value()); } |
79 | 85 |
|
80 | | -BoolOscModel::BoolOscModel( |
81 | | - SpaInstrument *inst_ref, const QString dest, bool val) : |
| 86 | +BoolOscModel::BoolOscModel(SpaInstrument *instRef, const QString dest, bool val) : |
82 | 87 | SpaOscModel<BoolModel>(val, nullptr, dest, false) |
83 | 88 | { |
84 | 89 | qDebug() << "LMMS: receiving bool model: val = " << val; |
85 | | - init(inst_ref, dest); |
| 90 | + init(instRef, dest); |
86 | 91 | QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc())); |
87 | 92 | } |
88 | 93 |
|
89 | | -IntOscModel::IntOscModel(SpaInstrument *inst_ref, const QString dest, int min, |
| 94 | +IntOscModel::IntOscModel(SpaInstrument *instRef, const QString dest, int min, |
90 | 95 | int max, int val) : |
91 | 96 | SpaOscModel<IntModel>(val, min, max, nullptr, dest, false) |
92 | 97 | { |
93 | 98 | qDebug() << "LMMS: receiving int model: (val, min, max) = (" << val |
94 | 99 | << ", " << min << ", " << max << ")"; |
95 | | - init(inst_ref, dest); |
| 100 | + init(instRef, dest); |
96 | 101 | QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc())); |
97 | 102 | } |
98 | 103 |
|
99 | | -FloatOscModel::FloatOscModel(SpaInstrument *inst_ref, const QString dest, |
| 104 | +FloatOscModel::FloatOscModel(SpaInstrument *instRef, const QString dest, |
100 | 105 | float min, float max, float val) : |
101 | 106 | SpaOscModel<FloatModel>(val, min, max, 0.1f, nullptr, dest, false) |
102 | 107 | /* TODO: get step from plugin (we currently need a plugin where this |
103 | 108 | can be tested) */ |
104 | 109 | { |
105 | 110 | qDebug() << "LMMS: receiving float model: (val, min, max) = (" << val |
106 | 111 | << ", " << min << ", " << max << ")"; |
107 | | - init(inst_ref, dest); |
| 112 | + init(instRef, dest); |
108 | 113 | QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc())); |
109 | 114 | } |
0 commit comments