LMMS
Loading...
Searching...
No Matches
Lv2ControlBase.h
Go to the documentation of this file.
1/*
2 * Lv2ControlBase.h - Lv2 control base class
3 *
4 * Copyright (c) 2018-2023 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_LV2_CONTROL_BASE_H
26#define LMMS_LV2_CONTROL_BASE_H
27
28#include "lmmsconfig.h"
29
30#ifdef LMMS_HAVE_LV2
31
32#include <lilv/lilv.h>
33#include <memory>
34
35#include "LinkedModelGroups.h"
36#include "lmms_export.h"
37#include "Plugin.h"
38
39namespace lmms
40{
41
42
43class Lv2Proc;
44class PluginIssue;
45class SampleFrame;
46
74class LMMS_EXPORT Lv2ControlBase : public LinkedModelGroups
75{
76public:
78 std::vector<PluginIssue> &issues);
79
80 void shutdown();
81 void init(Model* meAsModel);
82
83 const LilvPlugin* getPlugin() const { return m_plugin; }
84
85 Lv2Proc *control(std::size_t idx) { return m_procs[idx].get(); }
86 const Lv2Proc *control(std::size_t idx) const { return m_procs[idx].get(); }
87
88 bool hasGui() const { return m_hasGUI; }
89 void setHasGui(bool val) { m_hasGUI = val; }
90
91protected:
92 /*
93 ctor/dtor
94 */
98 Lv2ControlBase(class Model *that, const QString& uri);
100 ~Lv2ControlBase() override;
101 void reload();
102
104
105 /*
106 overrides
107 */
108 LinkedModelGroup* getGroup(std::size_t idx) override;
109 const LinkedModelGroup* getGroup(std::size_t idx) const override;
110
111 /*
112 utils for the run thread
113 */
116 void copyModelsFromLmms();
118 void copyModelsToLmms() const;
119
121 void copyBuffersFromLmms(const SampleFrame* buf, f_cnt_t frames);
123 void copyBuffersToLmms(SampleFrame* buf, f_cnt_t frames) const;
125 void run(f_cnt_t frames);
126
127 /*
128 load/save, must be called from virtuals
129 */
130 void saveSettings(QDomDocument &doc, QDomElement &that);
131 void loadSettings(const QDomElement &that);
132 void loadFile(const QString &file);
133
134 /*
135 more functions that must be called from virtuals
136 */
137 std::size_t controlCount() const;
138 QString nodeName() const { return "lv2controls"; }
139 bool hasNoteInput() const;
140 void handleMidiInputEvent(const class MidiEvent &event,
141 const class TimePos &time, f_cnt_t offset);
142
143private:
147 std::vector<std::unique_ptr<Lv2Proc>> m_procs;
148
149 bool m_hasGUI = false;
151
153};
154
155
156} // namespace lmms
157
158#endif // LMMS_HAVE_LV2
159
160#endif // LMMS_LV2_CONTROL_BASE_H
static void shutdown(void)
Definition adplugdb.cpp:297
static void run(LV2_Handle instance, uint32_t n_samples)
Definition bindings_test_plugin.c:112
#define check(expr)
Definition blargg_source.h:32
Definition LinkedModelGroups.h:54
Definition LinkedModelGroups.h:156
Definition Lv2ControlBase.h:75
Lv2ControlBase(const Lv2ControlBase &)=delete
void copyModelsFromLmms()
Definition Lv2ControlBase.cpp:126
const LilvPlugin * getPlugin() const
Definition Lv2ControlBase.h:83
Lv2Proc * control(std::size_t idx)
Definition Lv2ControlBase.h:85
~Lv2ControlBase() override
void reload()
Definition Lv2ControlBase.cpp:102
Lv2ControlBase & operator=(const Lv2ControlBase &)=delete
bool m_hasGUI
Definition Lv2ControlBase.h:149
const LilvPlugin * m_plugin
Definition Lv2ControlBase.h:152
std::size_t controlCount() const
Definition Lv2ControlBase.cpp:199
unsigned m_channelsPerProc
Definition Lv2ControlBase.h:150
const Lv2Proc * control(std::size_t idx) const
Definition Lv2ControlBase.h:86
bool hasGui() const
Definition Lv2ControlBase.h:88
void saveSettings(QDomDocument &doc, QDomElement &that)
Definition Lv2ControlBase.cpp:171
QString nodeName() const
Definition Lv2ControlBase.h:138
void copyModelsToLmms() const
Bring values from all ports to the LMMS core.
Definition Lv2ControlBase.cpp:133
void loadSettings(const QDomElement &that)
Definition Lv2ControlBase.cpp:181
void loadFile(const QString &file)
Definition Lv2ControlBase.cpp:191
void copyBuffersToLmms(SampleFrame *buf, f_cnt_t frames) const
Copy our ports into buffers passed by LMMS.
Definition Lv2ControlBase.cpp:153
void setHasGui(bool val)
Definition Lv2ControlBase.h:89
std::vector< std::unique_ptr< Lv2Proc > > m_procs
Definition Lv2ControlBase.h:147
LinkedModelGroup * getGroup(std::size_t idx) override
Definition Lv2ControlBase.cpp:110
void copyBuffersFromLmms(const SampleFrame *buf, f_cnt_t frames)
Copy buffer passed by LMMS into our ports.
Definition Lv2ControlBase.cpp:141
Lv2ControlBase(class Model *that, const QString &uri)
Definition Lv2ControlBase.cpp:53
Definition Lv2Proc.h:66
Definition MidiEvent.h:37
Definition Model.h:37
Type
Definition Plugin.h:76
Issue type bundled with informational string.
Definition PluginIssue.h:66
Definition SampleFrame.h:41
Definition TimePos.h:68
struct LilvPluginImpl LilvPlugin
Definition lilv.h:82
int val
Definition jpeglib.h:956
static SordNode * uri(SordWorld *world, int num)
Definition sord_test.c:47
Definition AudioAlsa.cpp:35
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43
ZCONST uch * init
Definition extract.c:2392
struct zdirent * file
Definition win32.c:1500