Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
bundled_plugin_finder.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "plugins/CLAPPluginFormat.h"
7#include "utils/file_path_list.h"
8
9#include <juce_audio_processors/juce_audio_processors.h>
10
11namespace zrythm::test_helpers
12{
13
18template <typename FormatType>
19std::unique_ptr<juce::PluginDescription>
20find_bundled_plugin_by_name (
21 const QString &search_paths_str,
22 const juce::String &target_name)
23{
24 if (search_paths_str.isEmpty ())
25 return nullptr;
26
27 auto paths = std::make_unique<utils::FilePathList> ();
28 QStringList path_list = search_paths_str.split (":::", Qt::SkipEmptyParts);
29 for (const auto &path : path_list)
30 paths->add_path (std::filesystem::path (path.toStdString ()));
31
32 if (paths->empty ())
33 return nullptr;
34
35 FormatType format;
36 auto juce_search_paths = paths->get_as_juce_file_search_path ();
37 auto identifiers =
38 format.searchPathsForPlugins (juce_search_paths, false, false);
39 for (const auto &id : identifiers)
40 {
41 juce::OwnedArray<juce::PluginDescription> descriptions;
42 format.findAllTypesForFile (descriptions, id);
43 for (const auto * desc : descriptions)
44 {
45 if (desc->name == target_name)
46 return std::make_unique<juce::PluginDescription> (*desc);
47 }
48 }
49 return nullptr;
50}
51
52inline std::unique_ptr<juce::PluginDescription>
53find_bundled_vst3_plugin_by_name (const juce::String &target_name)
54{
55 return find_bundled_plugin_by_name<juce::VST3PluginFormat> (
56 QStringLiteral (BUNDLED_VST3_SEARCH_PATHS), target_name);
57}
58
59inline std::unique_ptr<juce::PluginDescription>
60find_bundled_clap_plugin_by_name (const juce::String &target_name)
61{
62 return find_bundled_plugin_by_name<plugins::CLAPPluginFormat> (
63 QStringLiteral (BUNDLED_CLAP_SEARCH_PATHS), target_name);
64}
65
66} // namespace zrythm::test_helpers