Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2022 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "vstpluginmetareader.h"
24 :
25 : #include "audio/common/audiotypes.h"
26 :
27 : #include "vsttypes.h"
28 : #include "vstpluginattrs.h"
29 : #include "vsterrors.h"
30 :
31 : #include "log.h"
32 :
33 : using namespace muse;
34 : using namespace muse::audioplugins;
35 : using namespace muse::vst;
36 :
37 0 : audioplugins::PluginType VstPluginMetaReader::metaType() const
38 : {
39 0 : return std::string(AUDIO_RESOURCE_TYPE_NAME);
40 : }
41 :
42 0 : bool VstPluginMetaReader::canReadMeta(const io::path_t& pluginPath) const
43 : {
44 0 : return io::suffix(pluginPath) == VST3_PACKAGE_EXTENSION;
45 : }
46 :
47 0 : RetVal<PluginMetaList> VstPluginMetaReader::readMeta(const io::path_t& pluginPath) const
48 : {
49 0 : PluginModulePtr module = createModule(pluginPath);
50 0 : if (!module) {
51 0 : return make_ret(Err::NoPluginModule);
52 : }
53 :
54 0 : const auto& factory = module->getFactory();
55 0 : PluginMetaList result;
56 :
57 0 : for (const ClassInfo& classInfo : factory.classInfos()) {
58 0 : if (classInfo.category() != kVstAudioEffectClass) {
59 0 : continue;
60 : }
61 :
62 0 : PluginMeta meta;
63 0 : meta.id = io::completeBasename(pluginPath).toStdString();
64 0 : meta.type = AUDIO_RESOURCE_TYPE_NAME;
65 0 : meta.attributes.emplace(CATEGORIES_ATTRIBUTE, String::fromStdString(classInfo.subCategoriesString()));
66 0 : meta.attributes.emplace(muse::audio::HAS_NATIVE_EDITOR_SUPPORT_ATTRIBUTE, u"true");
67 0 : meta.vendor = classInfo.vendor();
68 :
69 0 : result.emplace_back(std::move(meta));
70 0 : break;
71 0 : }
72 :
73 0 : if (result.empty()) {
74 0 : return make_ret(Err::NoAudioEffect);
75 : }
76 :
77 0 : return RetVal<PluginMetaList>::make_ok(result);
78 0 : }
|