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

Initial support for CLAP plugins #7199

Draft
wants to merge 132 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
9c80041
Add CLAP 1.1.3 submodule
messmerd Dec 31, 2023
7b630bd
Add submodule again; Add CLAP to CMake
messmerd Dec 31, 2023
b443722
Remove CLAP submodule from old location
messmerd Dec 31, 2023
c51390c
Locate and init CLAP plugins
messmerd Dec 19, 2022
5e2866e
Add CLAP logo
messmerd Jan 22, 2023
ae61e5c
Update CLAP to version 1.1.6
messmerd Jan 22, 2023
1e17502
Add clap-helpers submodule
messmerd Jan 24, 2023
4992b2a
Refactor ClapManager
messmerd Jan 29, 2023
1617b05
Move ClapFile/ClapPlugin into their own source files
messmerd Jan 29, 2023
b088038
Add PluginIssueHash
messmerd Dec 31, 2023
230c953
Add missing ClapFile.h/cpp; Start implementing ClapPorts
messmerd Jan 29, 2023
2469d9f
Add ClapSubPluginFeatures
messmerd Jan 29, 2023
3de14c1
Add ClapEffect (currently non-functional)
messmerd Jan 29, 2023
ed63855
Improve effect description widget text
messmerd Jan 29, 2023
ee87f4e
Refactor to support plugin instances
messmerd Jan 30, 2023
987c9ff
More refactoring
messmerd Jan 31, 2023
10f48a6
Refactor + fix ownership issues
messmerd Feb 2, 2023
c20c075
Progress
messmerd Feb 13, 2023
1763e5a
Fix audio buffers and plugin state
messmerd Feb 13, 2023
0dd0905
Copy audio buffers; Implement CLAP_EXT_LOG
messmerd Feb 17, 2023
c3821d9
Fix crash when initializing some CLAP plugins
messmerd Feb 17, 2023
ec27096
Allocate audio buffers - some CLAP effects work now
messmerd Feb 17, 2023
4bede10
Fix crash, implement thread check extension, and more
messmerd Feb 24, 2023
35c7dcf
Fix edge case
messmerd Feb 24, 2023
c891ab2
Begin implementing params
messmerd Feb 26, 2023
01e2dd8
Minor changes
messmerd Mar 12, 2023
c1827fa
Progress on params
messmerd Mar 12, 2023
cdfea27
Parameter automation mostly works now
messmerd Mar 12, 2023
961e4f8
Use CheckControl; Minor improvements
messmerd Mar 13, 2023
b5b6ae3
Modify CustomTextKnob to provide "dynamic" text option
messmerd Dec 31, 2023
72e8034
Implement ClapControlBase::reload()
messmerd Apr 30, 2023
2fb00cc
Fix failed assert
messmerd May 1, 2023
cc397ab
Fix build
messmerd Dec 31, 2023
1c2326b
Update CLAP to version 1.1.8
messmerd Aug 28, 2023
7f171e3
Update clap-helpers
messmerd Aug 28, 2023
346595d
Fix crash when loading LSP plugin ports
messmerd Aug 28, 2023
b1923ff
Safer param creation
messmerd Sep 24, 2023
b3cb37e
Style fixes + better memory/thread safety
messmerd Sep 24, 2023
983838d
Fix build
messmerd Sep 25, 2023
a9cc62e
Stop using RTLD_DEEPBIND to allow ASan to work; Modify method names
messmerd Sep 25, 2023
eaf8f77
Fail gracefully when plugin parameter is invalid
messmerd Sep 25, 2023
dc32273
Implement transport event; Better state transitions
messmerd Dec 31, 2023
ca41492
Fix CLAP file deinit; Fix some memory issues; Minor changes
messmerd Sep 28, 2023
fe6166d
Use ArrayVector
messmerd Sep 30, 2023
8c4f78f
Param init improvements; Minor changes
messmerd Sep 30, 2023
084acd6
Add empty latency extension impl to prevent DISTRHO plugin crashes
messmerd Oct 1, 2023
2abc80d
Start implementing CLAP instruments
messmerd Oct 2, 2023
a0dd5fc
Ensure CLAP plugins start on main thread
messmerd Oct 2, 2023
7b38b5e
Fix null pointer dereference when input port doesn't exist
messmerd Oct 2, 2023
c37346a
Use ringbuffer for midi events
messmerd Oct 4, 2023
b782016
Support steady time
messmerd Oct 4, 2023
5e64b1e
Implement transport beats info; Set transport flags correctly
messmerd Oct 5, 2023
03773ba
Add ClapTransport class
messmerd Oct 6, 2023
77975ac
Refactor some window embedding code in preparation for CLAP GUI
messmerd Dec 31, 2023
4a48daf
Fix regression from previous commit
messmerd Oct 8, 2023
6919eef
Begin GUI implementation; Don't set constant_mask
messmerd Oct 10, 2023
63a356a
Implement MIDI key pressure event
messmerd Oct 10, 2023
0e3bbb8
Allow LMMS_CLAP_PATH env var to override all default CLAP search paths
messmerd Oct 11, 2023
1fdbaab
Attempt to fix restart method; Reimplement constant_mask
messmerd Oct 11, 2023
3e96224
Fix restart() and deactivate()
messmerd Oct 12, 2023
1f95248
Improve param value text; Improve extension init
messmerd Oct 22, 2023
70e817d
Implement note ports extension; Refactor log extension
messmerd Nov 2, 2023
8b2b2c2
Fix filesystem includes; Fix value_to_text() buffer size
messmerd Nov 3, 2023
9439574
Fix build
messmerd Nov 3, 2023
e5f2ceb
Fix some build issues
messmerd Nov 5, 2023
5ecfb76
Improve findSearchPaths()
messmerd Dec 4, 2023
bbdc9ae
Better way of ensuring plugins load on main thread
messmerd Dec 4, 2023
2b9e996
Fix some issues
messmerd Dec 4, 2023
599fe47
Fix scripted-checks
messmerd Dec 4, 2023
d872221
Update CLAP to version 1.1.10
messmerd Dec 4, 2023
27b4ea2
Fix instruments that have audio input
messmerd Dec 17, 2023
bbf328c
Use mingw.thread.h
messmerd Dec 17, 2023
5661141
Implement timer support extension
messmerd Dec 21, 2023
076511e
Improve timer support
messmerd Dec 21, 2023
1b18171
Implement thread pool extension
messmerd Dec 22, 2023
71c3095
Enable thread pool extension
messmerd Dec 22, 2023
3b0dea0
Begin refactoring CLAP extensions
messmerd Dec 24, 2023
08ac8cc
Continue refactoring CLAP extensions
messmerd Dec 24, 2023
7d9b581
Implement state extension (WIP)
messmerd Dec 27, 2023
bf7f600
Refactor thread check and params extensions (WIP)
messmerd Dec 29, 2023
f5dbc3b
Refactor gui extension
messmerd Dec 29, 2023
2c7e10f
Fix mistake in thread check extension
messmerd Dec 31, 2023
88386ec
Workaround for std::experimental::filesystem
messmerd Dec 31, 2023
6e83350
Refactor log extension
messmerd Jan 1, 2024
ba29c87
Fix build; Remove thread pool extension (needs more work)
messmerd Jan 2, 2024
337e5ca
Try to fix filesystem issues
messmerd Jan 2, 2024
80c5643
Try to fix builds
messmerd Jan 2, 2024
90a5b15
Clean up includes
messmerd Jan 3, 2024
189e142
More refactoring
messmerd Jan 3, 2024
5972559
Fix MSVC build
messmerd Jan 16, 2024
f654a1d
Cleanup; Use CLAP state when cloning tracks (WIP)
messmerd Jan 22, 2024
a5c4097
Fix state extension implementation and plugin cloning
messmerd Jan 23, 2024
e50d007
Update CLAP to version 1.2.0
messmerd Jan 26, 2024
f04a5bb
Add support for CLAP compatibility IDs; revert parameter value change
messmerd Jan 27, 2024
5af3d4d
Add hashCombine function
messmerd Feb 9, 2024
ad7bd3e
Begin work on presets (WIP)
messmerd Feb 11, 2024
60374db
More work on presets
messmerd Feb 12, 2024
73e3fde
Fix small timer support bug
messmerd Feb 12, 2024
dfe8ac4
Fix some issues in ClapPresetLoader::load()
messmerd Feb 13, 2024
63ef03d
More work on CLAP presets (WIP)
messmerd Feb 20, 2024
21d9168
Remember to deinit preset database
messmerd Feb 20, 2024
698d1c9
CLAP presets (WIP)
messmerd Mar 3, 2024
e502ad3
More progress on presets (WIP)
messmerd Mar 4, 2024
3c54c31
Try to fix build
messmerd Mar 7, 2024
bf85afe
Implement state context extension
messmerd Mar 7, 2024
763d69a
Presets and parameters (WIP)
messmerd Mar 9, 2024
575dd78
Presets bug fixes and refactoring (WIP)
messmerd Mar 16, 2024
148f5fc
Fix external presets
messmerd Mar 17, 2024
7e6dd39
Fix PresetSelector
messmerd Mar 17, 2024
c1662aa
Add preset load/save buttons; cleanup
messmerd Mar 18, 2024
feee422
Allow extension initialization within plugin.init() call
messmerd Mar 21, 2024
5b6bb75
Merge branch 'LMMS:master' into clap-host-dev
messmerd Mar 21, 2024
6063cdf
Fix ClapState::save() bug
messmerd Mar 23, 2024
1aac7a9
Add CLAP filter to EffectSelectDialog
messmerd Mar 24, 2024
f29e8ca
Minor changes
messmerd Mar 24, 2024
cb09644
New way of handling mono plugins (WIP)
messmerd Mar 26, 2024
92ebcf7
Remove LinkedModelGroup usage
messmerd Mar 27, 2024
3e5b433
Improve PluginPortConfig
messmerd Mar 28, 2024
d17a1d8
Add PluginPortConfigSelector
messmerd Mar 28, 2024
090bf82
Replace QComboBox with ComboBox
messmerd Mar 28, 2024
2b8e8d8
Fix Windows builds
messmerd Mar 28, 2024
f896536
Delay full extension init until after plugin.init()
messmerd Mar 29, 2024
b660556
Fix automation load/save regression
messmerd Apr 6, 2024
52b1214
Merge branch 'master' of https://github.com/messmerd/lmms into clap-h…
messmerd Apr 7, 2024
da893e2
Fix build
messmerd Apr 7, 2024
2b23635
Fix CLAP loading on macOS
messmerd Apr 18, 2024
1808474
Merge branch 'master' into clap-host-dev
messmerd May 28, 2024
4201279
Use std::filesystem; fix UTF-8 issues
messmerd May 29, 2024
0a3cb05
Fix build
messmerd May 29, 2024
b7ed5a0
Merge branch 'master' into clap-host-dev
messmerd Nov 7, 2024
0dec314
Fix build
messmerd Nov 7, 2024
1b3b091
Fix more build errors
messmerd Nov 7, 2024
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@
[submodule "src/3rdparty/hiir/hiir"]
path = src/3rdparty/hiir/hiir
url = https://github.com/LostRobotMusic/hiir
[submodule "src/3rdparty/clap/clap"]
path = src/3rdparty/clap/clap
url = https://github.com/free-audio/clap.git
[submodule "src/3rdparty/clap/clap-helpers"]
path = src/3rdparty/clap/clap-helpers
url = https://github.com/free-audio/clap-helpers.git
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ OPTION(WANT_OSS "Include Open Sound System support" ON)
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_CLAP "Include CLAP plugins" ON)
OPTION(WANT_CMT "Include Computer Music Toolkit LADSPA plugins" ON)
OPTION(WANT_JACK "Include JACK (Jack Audio Connection Kit) support" ON)
OPTION(WANT_WEAKJACK "Loosely link JACK libraries" ON)
Expand Down Expand Up @@ -276,6 +277,13 @@ ELSE(WANT_SUIL)
SET(STATUS_SUIL "not built as requested")
ENDIF(WANT_SUIL)

IF(WANT_CLAP)
SET(LMMS_HAVE_CLAP TRUE)
SET(STATUS_CLAP "OK")
ELSE(WANT_CLAP)
SET(STATUS_CLAP "not built as requested")
ENDIF(WANT_CLAP)

IF(WANT_CALF)
SET(LMMS_HAVE_CALF TRUE)
SET(STATUS_CALF "OK")
Expand Down Expand Up @@ -807,6 +815,7 @@ MESSAGE(
"----------------\n"
"* Lv2 plugins : ${STATUS_LV2}\n"
"* SUIL for plugin UIs : ${STATUS_SUIL}\n"
"* CLAP plugins : ${STATUS_CLAP}\n"
"* ZynAddSubFX instrument : ${STATUS_ZYN}\n"
"* Carla Patchbay & Rack : ${STATUS_CARLA}\n"
"* SoundFont2 player : ${STATUS_FLUIDSYNTH}\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 @@ -30,6 +30,8 @@ SET(LMMS_PLUGIN_LIST
CarlaBase
CarlaPatchbay
CarlaRack
ClapEffect
ClapInstrument
Compressor
CrossoverEQ
Delay
Expand Down
1 change: 1 addition & 0 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
QString displayValue( const float val ) const override;
} ;

// TODO: Add DoubleModel?

class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
{
Expand Down
165 changes: 165 additions & 0 deletions include/ClapAudioPorts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* ClapAudioPorts.h - Implements CLAP audio ports extension
*
* Copyright (c) 2024 Dalton Messmer <messmer.dalton/at/gmail.com>
*
* 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 LMMS_CLAP_AUDIO_PORTS_H
#define LMMS_CLAP_AUDIO_PORTS_H

#include "lmmsconfig.h"

#ifdef LMMS_HAVE_CLAP

#include <memory>
#include <vector>
#include <clap/ext/audio-ports.h>

#include "ClapExtension.h"
#include "lmms_basics.h"
#include "lmms_export.h"
#include "PluginIssue.h"
#include "PluginPortConfig.h"
#include "SampleFrame.h"

namespace lmms
{

//! RAII-enabled CLAP AudioBuffer
class ClapAudioBuffer
{
public:
ClapAudioBuffer(std::uint32_t channels, fpp_t frames)
: m_channels{channels}
, m_frames{frames}
{
if (channels == 0) { return; }
m_data = new float*[m_channels]();
for (std::uint32_t channel = 0; channel < m_channels; ++channel)
{
m_data[channel] = new float[m_frames]();
}
}

ClapAudioBuffer(const ClapAudioBuffer&) = delete;
auto operator=(const ClapAudioBuffer&) -> ClapAudioBuffer& = delete;

ClapAudioBuffer(ClapAudioBuffer&& other) noexcept
: m_channels{std::exchange(other.m_channels, 0)}
, m_frames{std::exchange(other.m_frames, 0)}
, m_data{std::exchange(other.m_data, nullptr)}
{
}

auto operator=(ClapAudioBuffer&& other) noexcept -> ClapAudioBuffer&
{
if (this != &other)
{
free();
m_channels = std::exchange(other.m_channels, 0);
m_frames = std::exchange(other.m_frames, 0);
m_data = std::exchange(other.m_data, nullptr);
}
return *this;
}

~ClapAudioBuffer() { free(); }

//! [channel][frame]
auto data() const -> float** { return m_data; }

private:

Check notice on line 89 in include/ClapAudioPorts.h

View check run for this annotation

codefactor.io / CodeFactor

include/ClapAudioPorts.h#L89

Do not leave a blank line after "private:" (whitespace/blank_line)

void free() noexcept
{
if (!m_data) { return; }
for (std::uint32_t channel = 0; channel < m_channels; ++channel)
{
if (m_data[channel]) { delete[] m_data[channel]; }
}
delete[] m_data;
}

std::uint32_t m_channels;
fpp_t m_frames;
float** m_data = nullptr;
};

class LMMS_EXPORT ClapAudioPorts final
: public ClapExtension<clap_host_audio_ports, clap_plugin_audio_ports>
, public PluginPortConfig
{
public:
ClapAudioPorts(ClapInstance* parent);
~ClapAudioPorts() override;

auto init(clap_process& process) noexcept -> bool;

auto extensionId() const -> std::string_view override { return CLAP_EXT_AUDIO_PORTS; }

void copyBuffersFromCore(const SampleFrame* buffer, fpp_t frames);
void copyBuffersToCore(SampleFrame* buffer, fpp_t frames) const;

private:
auto hostExtImpl() const -> const clap_host_audio_ports* override { return nullptr; } // not impl for host yet
auto checkSupported(const clap_plugin_audio_ports& ext) -> bool override;

std::vector<PluginIssue> m_issues; // TODO: Remove?

/**
* Process-related
*/
std::vector<clap_audio_buffer_t> m_audioIn, m_audioOut;
clap_audio_buffer_t* m_audioInActive = nullptr; //!< Pointer to m_audioIn element used by LMMS
clap_audio_buffer_t* m_audioOutActive = nullptr; //!< Pointer to m_audioOut element used by LMMS

std::vector<ClapAudioBuffer> m_audioInBuffers, m_audioOutBuffers; //!< [port][channel][frame]

/**
* Ports
*/
enum class AudioPortType
{
Unsupported,
Mono,
Stereo
};

struct AudioPort
{
clap_audio_port_info info{};
std::uint32_t index = 0; //!< Index on plugin side, not m_audioPorts***
bool isInput = false;
PluginPortConfig::PortType type = PluginPortConfig::PortType::None; // None = unsupported
bool used = false; //!< In use by LMMS
};

std::vector<AudioPort> m_audioPortsIn, m_audioPortsOut;
AudioPort* m_audioPortInActive = nullptr; //!< Pointer to m_audioPortsIn element used by LMMS
AudioPort* m_audioPortOutActive = nullptr; //!< Pointer to m_audioPortsOut element used by LMMS

Check notice on line 157 in include/ClapAudioPorts.h

View check run for this annotation

codefactor.io / CodeFactor

include/ClapAudioPorts.h#L157

Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)

};

} // namespace lmms

#endif // LMMS_HAVE_CLAP

#endif // LMMS_CLAP_AUDIO_PORTS_H
Loading
Loading