Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SPA support (enabling zyn-fusion) #4662

Draft
wants to merge 143 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
5a26e8c
Implement spa plugin
Dec 18, 2017
94908ce
Allow converting old zyn to new one
JohannesLorenz Sep 15, 2018
e81f9b0
Fix instrument converting
PhysSong Oct 19, 2018
1a5c0e0
Refactor getting Automatable Models to Engine
JohannesLorenz Oct 22, 2018
7e7044d
Allow dropping automation in more ways
JohannesLorenz Oct 22, 2018
da9fcfc
Allow drag-dropping onto Controller Rack
JohannesLorenz Nov 1, 2018
bdde4e3
Automized formatting changes only
JohannesLorenz Nov 1, 2018
1e091ea
Manual formatting changes only
JohannesLorenz Nov 2, 2018
42c0041
Fix instrument converting (thanks to @PhysSong)
JohannesLorenz Nov 3, 2018
2a4ad86
Make all spa includes optional
JohannesLorenz Nov 5, 2018
61d0e19
Move SpaInstrument.* to src/core
JohannesLorenz Nov 6, 2018
610d92e
Abstrahize SpaInstrument into "SpaPluginBase" and "SpaControlBase"
JohannesLorenz Nov 28, 2018
0c03c5c
Add and implement SPA effects
JohannesLorenz Nov 28, 2018
77556fd
Read step from SPA float controls
JohannesLorenz Nov 29, 2018
87918f6
Merge branch 'master' into osc-plugin
JohannesLorenz Dec 1, 2018
be995fb
Turn SPA core plugins into sub plugins
JohannesLorenz Dec 30, 2018
625f022
Merge branch 'master' into osc-plugin
JohannesLorenz Dec 30, 2018
cb97719
Merge branch 'instr-sub-plugins' into spa-work
JohannesLorenz Dec 31, 2018
b110f5e
Merge branch 'master' into spa-work
JohannesLorenz Dec 31, 2018
1be5cb3
Remove debug output
JohannesLorenz Dec 31, 2018
cd7d099
Merge branch 'spa-work' into osc-plugin
JohannesLorenz Dec 31, 2018
d4765d2
Minor cleanups
JohannesLorenz Jan 1, 2019
7e96117
Elliminate useless SpaPluginBase class
JohannesLorenz Jan 1, 2019
07666ac
Fix compile fail if SPA is disabled
JohannesLorenz Jan 1, 2019
9e21421
Cleanups, non functional
JohannesLorenz Jan 1, 2019
74e0afb
Merge branch 'master' into osc-plugin
JohannesLorenz Jan 1, 2019
3a4edc2
Merge branch 'master' into osc-plugin
JohannesLorenz Jan 2, 2019
4949059
Use QString for SubPluginFeatures' virtuals
JohannesLorenz Jan 18, 2019
0725d3a
Refactor spa views into SpaViewBase
JohannesLorenz Jan 19, 2019
d4c3d9c
Set models when model changed
JohannesLorenz Jan 19, 2019
e43d68e
Add Control classes
JohannesLorenz Mar 16, 2019
f586bac
Add linked model groups
JohannesLorenz Mar 16, 2019
2221d21
Fix wrong display names
JohannesLorenz Mar 21, 2019
f6726c4
Merge branch 'master' into instr-sub-plugins
JohannesLorenz Mar 22, 2019
8f71569
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Mar 22, 2019
827e73f
Bugfix for SubPluginFeature's return types
JohannesLorenz Mar 22, 2019
1220277
Simplify LinkedModelGroups usage
JohannesLorenz Mar 23, 2019
e6e27d2
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Mar 24, 2019
e9bf431
Fix memory cleanup
JohannesLorenz Apr 22, 2019
33df80b
Merge branch 'model-visitor' into linked-model-groups
JohannesLorenz Apr 27, 2019
b0758c1
Simplify LinkedModelGroups usage
JohannesLorenz Mar 23, 2019
dae999d
Code conventions + Merge fixes
JohannesLorenz Apr 27, 2019
27f62e6
Do not store nProc in LinkedModelGroup
JohannesLorenz Apr 27, 2019
b23fd06
Improve LinkedModelGroups member funcs
JohannesLorenz Apr 30, 2019
7d91d9b
LinkedModelGroups: Fix possible OOB read
JohannesLorenz May 15, 2019
82cba06
LinkedModelGroups: Hide if no controls
JohannesLorenz May 15, 2019
6c474fe
LinkedModelGroupViews: Fix comment
JohannesLorenz May 15, 2019
08c49a3
LinkedModelGroups: Move model into struct
JohannesLorenz May 15, 2019
78dee7d
LinkedModelGroups: Implement load/save
JohannesLorenz May 16, 2019
993fa46
Coding conventions
JohannesLorenz May 16, 2019
3e0525d
LinkedModelGroups: Fix nullptr indirection
JohannesLorenz May 25, 2019
029c2e4
Remove unused variable
JohannesLorenz May 26, 2019
2edb35e
LinkedModelGroups: Don't save linked models twice
JohannesLorenz May 27, 2019
24ca9f1
Code review
JohannesLorenz May 30, 2019
0c1758e
Review rework, thanks to @DomClark
JohannesLorenz Jun 13, 2019
2ad9db6
Update connect instructions
JohannesLorenz Jun 18, 2019
538b5a5
Fix assertion for #LinkedModelGroups == 1
JohannesLorenz Jul 26, 2019
dcd7482
LinkedModelGroups: Priv members -> nested struct
JohannesLorenz Jul 22, 2019
2ce0b7f
Implement clearing models
JohannesLorenz Jul 22, 2019
b3d1fb1
Hide model vector in derived classes
JohannesLorenz Jul 23, 2019
0960b06
Fix unique_ptr compiler issues
JohannesLorenz Jul 24, 2019
8371dea
Use LinkedModelGroups
JohannesLorenz Apr 26, 2019
2dda00c
Merge linked-model-groups into osc-plugin-laptop
JohannesLorenz Jul 28, 2019
f6125f0
Remove Mutex and includes
JohannesLorenz Jul 6, 2019
7881211
Load/save states work, reload missing yet (samplerate)
JohannesLorenz Jul 6, 2019
17bae5f
Enable reloading partially (models are not saved yet)
JohannesLorenz Jul 22, 2019
d71554d
Merge branch 'linked-model-groups' into osc-plugin-laptop
JohannesLorenz Jul 28, 2019
dd08aa4
Solely split SpaControlBase.h to itself + SpaProc.h
JohannesLorenz Jul 17, 2019
2ba3fec
Controls: allow to return model view
JohannesLorenz Dec 4, 2019
99cb22a
Implement LinkedModelGroupLayout
JohannesLorenz Dec 4, 2019
87ec01d
Merge branch linked-model-groups into osc-plugin
JohannesLorenz Dec 4, 2019
5955e37
LinkedModelGroups: Always keep groups linked
JohannesLorenz Dec 5, 2019
9654921
Merge branch linked-model-groups into osc-plugin
JohannesLorenz Dec 5, 2019
d0b7dc1
Remove linking LEDs
JohannesLorenz Dec 8, 2019
3c5a5c7
Merge branch 'linked-model-groups' into HEAD
JohannesLorenz Dec 8, 2019
94ea93e
Show only one processor view
JohannesLorenz Dec 8, 2019
ba6fc9a
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 8, 2019
74ad422
Minor cleanups, doc cleanups
JohannesLorenz Dec 10, 2019
2cef3a1
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 10, 2019
68777ef
Whitespace or non-functional fixes
JohannesLorenz Dec 10, 2019
9e971f6
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 10, 2019
be056e7
Fix broken doc/wiki submodule
JohannesLorenz Dec 10, 2019
36f1e6a
Do no set minimumSize for the view
JohannesLorenz Dec 11, 2019
a34929a
Disable buggy VST plugins during PR
JohannesLorenz Dec 18, 2019
8e5a665
Forgot to remove code after merge
JohannesLorenz Dec 18, 2019
98f9a96
Fix OSC ringbuffer race condition
JohannesLorenz Dec 18, 2019
1404365
Fix load/save order: states before ports
JohannesLorenz Dec 19, 2019
d32927c
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 21, 2019
23b6b1d
Rename LinkedModelGroupLayout to ControlLayout
JohannesLorenz Dec 21, 2019
5ce97a2
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 29, 2019
464137a
RemotePlugin: Take fix from stable-1.2
JohannesLorenz Dec 29, 2019
61fed4a
Fix segfaults in zynaddsubfx
JohannesLorenz Dec 29, 2019
14c72b0
Implement LinkedModelGroup::containsModel
JohannesLorenz Dec 30, 2019
7d4bb11
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 30, 2019
ac6f014
Fix loading models not creating them
JohannesLorenz Dec 30, 2019
f8fbbac
Temporary fix to wait for zyn to load
JohannesLorenz Jan 2, 2020
6641380
Style fixes, thanks to @Veratil
JohannesLorenz Jan 2, 2020
cf23825
LinkedModelGroup::ModelInfo: Delete default CTOR
JohannesLorenz Jan 2, 2020
0ff1877
Try to fix CI error
JohannesLorenz Jan 2, 2020
0a97c6b
Fix broken wiki submodule
JohannesLorenz Jan 2, 2020
cc37562
Merge branch misc-lv2-preparation into osc-plugin
JohannesLorenz Jan 6, 2020
d38fec3
Merge branch 'instr-sub-plugins' into osc-plugin
JohannesLorenz Jan 6, 2020
87c4a03
Delete ModelInfo default CTOR
JohannesLorenz Jan 27, 2020
c6a28ed
LinkedModelGroup: Implement eraseModel() and getModel()
JohannesLorenz Jan 27, 2020
696ab26
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Jan 27, 2020
5d77256
SpaProc: Remove m_connectedModels
JohannesLorenz Jan 27, 2020
eeb1ef2
Add helpful comments
JohannesLorenz Feb 9, 2020
c9f03ba
Move removeControl from subclasses into this class
JohannesLorenz Feb 9, 2020
5e40771
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Feb 9, 2020
9f59841
Fix loading not adding models into GUI
JohannesLorenz Feb 9, 2020
210d704
Detect search bar by name, not by position
JohannesLorenz Feb 12, 2020
0c79331
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Feb 12, 2020
2c6d39c
Merge branch 'master' into osc-plugin-laptop
JohannesLorenz Mar 1, 2020
3e42df1
Merge branch 'master' into osc-plugin
JohannesLorenz Sep 12, 2020
af0a98a
Avoid use of osc DnD strings in the core UI
JohannesLorenz Sep 27, 2020
e62d478
Merge branch 'master' into osc-plugin
JohannesLorenz Nov 29, 2020
da61238
Merge branch 'master' into osc-plugin-merge
JohannesLorenz Feb 28, 2021
3c94a6e
Use the new SPA v0.0.3 ringbuffers
JohannesLorenz Mar 6, 2021
5c89ad0
Merge branch 'master' into osc-plugin-merge
JohannesLorenz Mar 6, 2021
8bcf420
Fix memory errors dropping xmz
JohannesLorenz Mar 7, 2021
93f42f8
Fix bug from prev commit
JohannesLorenz Mar 7, 2021
05b6644
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 13, 2021
ea0066c
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 21, 2021
2228da5
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 21, 2021
7f1dd04
Update zyn submodule
JohannesLorenz Sep 28, 2021
f322ec4
Merge branch 'master' into osc-plugin
JohannesLorenz Sep 28, 2021
885c16f
Merge branch 'master' into osc-plugin
JohannesLorenz Oct 30, 2021
8aeb766
Merge branch 'master' into osc-plugin
JohannesLorenz Nov 5, 2021
dfe4032
Fixup osc-plugin after merge of master
JohannesLorenz Jan 30, 2022
b8af8b0
Add .clang-format and .clang-tidy
JohannesLorenz Nov 1, 2018
d358a70
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 16, 2022
204a160
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 16, 2022
a3925a6
Fixup merge issues
JohannesLorenz Apr 16, 2022
21045b8
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 30, 2022
4b331e9
Fix ringbuffer concurrent read
JohannesLorenz May 1, 2022
bec4deb
Fix segfault at closing projects
JohannesLorenz May 1, 2022
1a9865e
Revert "Fix segfault at closing projects"
JohannesLorenz May 13, 2022
8a7908e
Remove .clang-* files (they should not be in this branch)
JohannesLorenz Jun 9, 2022
4f28410
Merge branch 'master' into osc-plugin
JohannesLorenz Jun 9, 2022
76a43d4
Merge commit '7227c89847a5472f322ae6a0702027dda18b0bc7~1' into osc-pl…
JohannesLorenz Jun 19, 2022
3c457af
Merge branch 'master' (early part) into osc-plugin
JohannesLorenz Jun 23, 2022
93d0d8f
Merge branch 'master' into osc-plugin
JohannesLorenz Jun 23, 2022
81d9458
Fix merge conflicts (namespace lmms)
JohannesLorenz Jul 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ OPTION(WANT_CALF "Include CALF LADSPA plugins" ON)
OPTION(WANT_CAPS "Include C* Audio Plugin Suite (LADSPA plugins)" ON)
OPTION(WANT_CARLA "Include Carla plugin" ON)
OPTION(WANT_CMT "Include Computer Music Toolkit LADSPA plugins" ON)
OPTION(WANT_SPA "Include SPA plugins" ON)
OPTION(WANT_JACK "Include JACK (Jack Audio Connection Kit) support" ON)
OPTION(WANT_WEAKJACK "Loosely link JACK libraries" ON)
OPTION(WANT_LV2 "Include Lv2 plugins" ON)
Expand Down Expand Up @@ -276,6 +277,25 @@ ELSE(WANT_TAP)
ENDIF(WANT_TAP)


IF(WANT_SPA)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LIBSPA spa)
IF(${LIBSPA_FOUND})
INCLUDE_DIRECTORIES(${LIBSPA_INCLUDE_DIRS})
LINK_DIRECTORIES(${LIBSPA_LIBRARY_DIRS})
SET(LMMS_HAVE_SPA TRUE)
SET(STATUS_SPA "OK")
ELSE()
SET(STATUS_SPA "not found, install it or set PKG_CONFIG_PATH appropriately")
ENDIF()
ELSE()
SET(STATUS_SPA "not found, requires pkg-config")
ENDIF()
ELSE(WANT_SPA)
SET(STATUS_SPA "not built as requested")
ENDIF(WANT_SPA)


# check for CARLA
IF(WANT_CARLA)
PKG_CHECK_MODULES(CARLA carla-native-plugin)
Expand Down Expand Up @@ -764,6 +784,7 @@ MESSAGE(
"* CMT LADSPA plugins : ${STATUS_CMT}\n"
"* TAP LADSPA plugins : ${STATUS_TAP}\n"
"* SWH LADSPA plugins : ${STATUS_SWH}\n"
"* SPA plugin API : ${STATUS_SPA}\n"
"* GIG player : ${STATUS_GIG}\n"
)

Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/PluginList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ SET(LMMS_PLUGIN_LIST
Sf2Player
Sfxr
Sid
SpaEffect
SpaInstrument
SpectrumAnalyzer
StereoEnhancer
StereoMatrix
Expand Down
6 changes: 4 additions & 2 deletions include/Clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QMap>
#include <QDomElement>
class QMimeData;

class QMimeData;

Expand All @@ -36,6 +37,7 @@ namespace lmms::Clipboard
enum class MimeType
{
StringPair,
Osc,
Default
};

Expand All @@ -58,11 +60,11 @@ namespace lmms::Clipboard
{
case MimeType::StringPair:
return "application/x-lmms-stringpair";
break;
case MimeType::Osc:
return "application/x-osc-stringpair";
case MimeType::Default:
default:
return "application/x-lmms-clipboard";
break;
}
}

Expand Down
8 changes: 8 additions & 0 deletions include/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ class LMMS_EXPORT ConfigManager : public QObject
return m_dataDir + TRACK_ICON_PATH;
}

const QString & spaDir() const
{
return m_spaDir;
}


const QString recoveryFile() const
{
return m_workingDir + "recover.mmp";
Expand Down Expand Up @@ -258,6 +264,7 @@ class LMMS_EXPORT ConfigManager : public QObject
void setLADSPADir(const QString & ladspaDir);
void setSF2Dir(const QString & sf2Dir);
void setSF2File(const QString & sf2File);
void setSPADir(const QString & sd);
void setSTKDir(const QString & stkDir);
void setGIGDir(const QString & gigDir);
void setThemeDir(const QString & themeDir);
Expand Down Expand Up @@ -288,6 +295,7 @@ class LMMS_EXPORT ConfigManager : public QObject
QString m_dataDir;
QString m_vstDir;
QString m_ladspaDir;
QString m_spaDir;
QString m_sf2Dir;
#ifdef LMMS_HAVE_FLUIDSYNTH
QString m_sf2File;
Expand Down
2 changes: 2 additions & 0 deletions include/ControllerRackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public slots:

protected:
void closeEvent( QCloseEvent * _ce ) override;
virtual void dragEnterEvent( QDragEnterEvent *dee );
virtual void dropEvent( QDropEvent * de );

private slots:
void addController();
Expand Down
3 changes: 2 additions & 1 deletion include/ControllerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public slots:
void contextMenuEvent( QContextMenuEvent * _me ) override;
void modelChanged() override;
void mouseDoubleClickEvent( QMouseEvent * event ) override;

virtual void dragEnterEvent( QDragEnterEvent *dee );
virtual void dropEvent( QDropEvent * de );

private:
QMdiSubWindow * m_subWindow;
Expand Down
18 changes: 18 additions & 0 deletions include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ class LMMS_EXPORT Engine : public QObject
return s_ladspaManager;
}

#ifdef LMMS_HAVE_SPA
static class SpaManager * getSPAManager()
{
return s_spaManager;
}
#endif

static void addPluginByPort(unsigned port, class Plugin* plug);

static float framesPerTick()
{
return s_framesPerTick;
Expand All @@ -115,6 +124,8 @@ class LMMS_EXPORT Engine : public QObject
return s_instanceOfMe;
}

static class AutomatableModel*
getAutomatableModel(const QString &val, bool hasPort);
static void setDndPluginKey(void* newKey);
static void* pickDndPluginKey();

Expand All @@ -123,6 +134,9 @@ class LMMS_EXPORT Engine : public QObject


private:
static class AutomatableModel*
getAutomatableModelAtPort(const QString& val, const QUrl& url);

// small helper function which sets the pointer to NULL before actually deleting
// the object it refers to
template<class T>
Expand All @@ -146,6 +160,10 @@ class LMMS_EXPORT Engine : public QObject
static class Lv2Manager* s_lv2Manager;
#endif
static Ladspa2LMMS* s_ladspaManager;
#ifdef LMMS_HAVE_SPA
static class SpaManager* s_spaManager;
#endif
static QMap<unsigned, class Plugin*> s_pluginsByPort;
static void* s_dndPluginKey;

// even though most methods are static, an instance is needed for Qt slots/signals
Expand Down
16 changes: 16 additions & 0 deletions include/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject
//! Create a view for the model
gui::PluginView * createView( QWidget * parent );

//! If the plugin offers to identify controls as strings (aka "ports",
//! like OSC does), this shall return the AutomatableModel for given
//! port or nullptr if there's none at that port
virtual class AutomatableModel *modelAtPort(const class QString &)
{
return nullptr;
}

//! If the plugin has a network port where it can be reached, this
//! should return that port; if not, it should return 0
virtual unsigned netPort(std::size_t channel) const
{
(void)channel;
return 0;
}

protected:
//! Create a view for the model
virtual gui::PluginView* instantiateView( QWidget * ) = 0;
Expand Down
4 changes: 4 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private slots:
void toggleDisableBackup(bool enabled);
void toggleOpenLastProject(bool enabled);
void setLanguage(int lang);
void setSPADir(const QString& ld);

// Performance settings widget.
void setAutoSaveInterval(int time);
Expand Down Expand Up @@ -116,6 +117,7 @@ private slots:
void setVSTDir(const QString & vstDir);
void openLADSPADir();
void setLADSPADir(const QString & ladspaDir);
void openSPADir();
void openSF2Dir();
void setSF2Dir(const QString & sf2Dir);
void openSF2File();
Expand Down Expand Up @@ -192,6 +194,7 @@ private slots:
QString m_workingDir;
QString m_vstDir;
QString m_ladspaDir;
QString m_spaDir;
QString m_gigDir;
QString m_sf2Dir;
#ifdef LMMS_HAVE_FLUIDSYNTH
Expand All @@ -204,6 +207,7 @@ private slots:
QLineEdit * m_vstDirLineEdit;
QLineEdit * m_themeDirLineEdit;
QLineEdit * m_ladspaDirLineEdit;
QLineEdit * m_spaLineEdit;
QLineEdit * m_gigDirLineEdit;
QLineEdit * m_sf2DirLineEdit;
#ifdef LMMS_HAVE_FLUIDSYNTH
Expand Down
121 changes: 121 additions & 0 deletions include/SpaControlBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* SpaControlBase.h - implementation of SPA interface
*
* Copyright (c) 2018-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef SPA_CONTROL_BASE_H
#define SPA_CONTROL_BASE_H

#include "lmmsconfig.h"

#ifdef LMMS_HAVE_SPA

//#include <QMutex>
#include <QString>
#include <memory>
#include <vector>

// general LMMS includes
#include "DataFile.h"
#include "LinkedModelGroups.h"
#include "lmms_basics.h"

// includes from the spa library
#include <spa/spa_fwd.h>

namespace lmms
{

namespace gui
{
class SpaViewBase;
}

class SpaProc;

class SpaControlBase : public LinkedModelGroups
{
friend class gui::SpaViewBase;
public:
SpaControlBase(Model *that, const QString &uniqueName,
DataFile::Types settingsType);
~SpaControlBase() override;

std::vector<std::unique_ptr<SpaProc>>& controls() { return m_procs; }

void saveSettings(QDomDocument &doc, QDomElement &that);
void loadSettings(const QDomElement &that);

// void writeOsc(const char *dest, const char *args, va_list va) {}
// void writeOsc(const char *dest, const char *args, ...) {}

void loadFile(const QString &file, bool user);

const spa::descriptor *m_spaDescriptor = nullptr;
bool hasUi() const;
void uiExtShow(bool doShow);
void copyModelsFromLmms();
void copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames);
void copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const;
void run(unsigned frames);

AutomatableModel *modelAtPort(const QString &dest);
void writeOscToAll(const char *dest, const char *args, va_list va);
void writeOscToAll(const char *dest, const char *args...);
protected:
void reloadPlugin() { /* TODO */ }
bool isValid() { return m_valid; }

private:
bool m_valid = true;

virtual void setNameFromFile(const QString &fname) = 0;

Model* m_that;

protected:

LinkedModelGroup* getGroup(std::size_t idx) override;
const LinkedModelGroup* getGroup(std::size_t idx) const override;

/* bool initPlugin() {}
void shutdownPlugin() {}*/

bool m_hasGUI = false;
bool m_loaded;

QString nodeName() const { return "spacontrols"; }

std::vector<std::unique_ptr<SpaProc>> m_procs;

void handleMidiInputEvent(const class MidiEvent &event,
const class TimePos &time, f_cnt_t offset);

private:
unsigned m_channelsPerProc;
};

} // namespace lmms

#endif // LMMS_HAVE_SPA

#endif // SPA_CONTROL_BASE_H
Loading