LMMS
Loading...
Searching...
No Matches
Lv2Instrument.h
Go to the documentation of this file.
1/*
2 * Lv2Instrument.h - implementation of LV2 instrument
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 LV2_INSTRUMENT_H
26#define LV2_INSTRUMENT_H
27
28#include <QString>
29#include <array>
30
31#include "Instrument.h"
32#include "InstrumentView.h"
33#include "Lv2ControlBase.h"
34#include "Lv2ViewBase.h"
35#include "Note.h"
36
37// whether to use MIDI vs playHandle
38// currently only MIDI works
39#define LV2_INSTRUMENT_USE_MIDI
40
41namespace lmms
42{
43
44namespace gui
45{
46
47class Lv2InsView;
48
49}
50
52{
53 Q_OBJECT
54signals:
56public:
57 /*
58 initialization
59 */
60 Lv2Instrument(InstrumentTrack *instrumentTrackArg,
61 Descriptor::SubPluginFeatures::Key* key);
62 ~Lv2Instrument() override;
63 void reload();
65
66 /*
67 load/save
68 */
69 void saveSettings(QDomDocument &doc, QDomElement &that) override;
70 void loadSettings(const QDomElement &that) override;
71 void loadFile(const QString &file) override;
72
73 /*
74 realtime funcs
75 */
76 bool hasNoteInput() const override { return Lv2ControlBase::hasNoteInput(); }
77#ifdef LV2_INSTRUMENT_USE_MIDI
78 bool handleMidiEvent(const MidiEvent &event,
79 const TimePos &time = TimePos(), f_cnt_t offset = 0) override;
80#else
81 void playNote(NotePlayHandle *nph, SampleFrame*) override;
82#endif
83 void play(SampleFrame* buf) override;
84
85 /*
86 misc
87 */
88 gui::PluginView* instantiateView(QWidget *parent) override;
89
90private slots:
91 void updatePitchRange();
92
93private:
94 QString nodeName() const override;
95
96#ifdef LV2_INSTRUMENT_USE_MIDI
97 std::array<int, NumKeys> m_runningNotes = {};
98#endif
99 void clearRunningNotes();
100
101 friend class gui::Lv2InsView;
102};
103
104
105namespace gui
106{
107
108
110{
111Q_OBJECT
112public:
113 Lv2InsView(Lv2Instrument *_instrument, QWidget *_parent);
114
115protected:
116 void dragEnterEvent(QDragEnterEvent *_dee) override;
117 void dropEvent(QDropEvent *_de) override;
118 void hideEvent(QHideEvent* event) override;
119
120private:
121 void modelChanged() override;
122};
123
124
125} // namespace gui
126
127
128} // namespace lmms
129
130#endif // LV2_INSTRUMENT_H
Instrument(InstrumentTrack *_instrument_track, const Descriptor *_descriptor, const Descriptor::SubPluginFeatures::Key *key=nullptr, Flags flags=Flag::NoFlags)
Definition Instrument.cpp:38
virtual void playNote(NotePlayHandle *, SampleFrame *)
Definition Instrument.h:82
Definition InstrumentTrack.h:62
bool hasNoteInput() const
Definition Lv2ControlBase.cpp:208
Lv2ControlBase(class Model *that, const QString &uri)
Definition Lv2ControlBase.cpp:53
Definition Lv2Instrument.h:52
QString nodeName() const override
Definition Lv2Instrument.cpp:220
void loadFile(const QString &file) override
Definition Lv2Instrument.cpp:156
void onSampleRateChanged()
Definition Lv2Instrument.cpp:129
~Lv2Instrument() override
Definition Lv2Instrument.cpp:100
bool handleMidiEvent(const MidiEvent &event, const TimePos &time=TimePos(), f_cnt_t offset=0) override
Definition Lv2Instrument.cpp:165
std::array< int, NumKeys > m_runningNotes
Definition Lv2Instrument.h:97
bool hasNoteInput() const override
Definition Lv2Instrument.h:76
void loadSettings(const QDomElement &that) override
Definition Lv2Instrument.cpp:148
gui::PluginView * instantiateView(QWidget *parent) override
Create a view for the model.
Definition Lv2Instrument.cpp:203
void clearRunningNotes()
Definition Lv2Instrument.cpp:119
void saveSettings(QDomDocument &doc, QDomElement &that) override
Definition Lv2Instrument.cpp:140
void reload()
Definition Lv2Instrument.cpp:109
void updatePitchRange()
Definition Lv2Instrument.cpp:211
void play(SampleFrame *buf) override
Definition Lv2Instrument.cpp:188
Lv2Instrument(InstrumentTrack *instrumentTrackArg, Descriptor::SubPluginFeatures::Key *key)
Definition Lv2Instrument.cpp:74
Definition MidiEvent.h:37
Definition NotePlayHandle.h:48
const Descriptor::SubPluginFeatures::Key & key() const
Definition Plugin.h:266
Definition SampleFrame.h:41
Definition TimePos.h:68
InstrumentView(Instrument *_instrument, QWidget *_parent)
Definition InstrumentView.cpp:34
Definition Lv2Instrument.h:110
void dragEnterEvent(QDragEnterEvent *_dee) override
Definition Lv2Instrument.cpp:258
void dropEvent(QDropEvent *_de) override
Definition Lv2Instrument.cpp:280
void hideEvent(QHideEvent *event) override
Definition Lv2Instrument.cpp:296
Lv2InsView(Lv2Instrument *_instrument, QWidget *_parent)
Definition Lv2Instrument.cpp:236
void modelChanged() override
Definition Lv2Instrument.cpp:305
Lv2ViewBase(class QWidget *pluginWidget, Lv2ControlBase *ctrlBase)
Definition Lv2ViewBase.cpp:140
Definition PluginView.h:36
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43
GUI::ui_handle_t gui
Definition main.cpp:50
struct zdirent * file
Definition win32.c:1500