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) 2021 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 "vstfxresolver.h"
24 :
25 : #include "vstfxprocessor.h"
26 :
27 : #include "log.h"
28 :
29 : using namespace muse::vst;
30 : using namespace muse::audio;
31 : using namespace muse::audio::fx;
32 :
33 0 : AudioResourceMetaList VstFxResolver::resolveResources() const
34 : {
35 0 : return pluginModulesRepo()->fxModulesMeta();
36 : }
37 :
38 0 : void VstFxResolver::refresh()
39 : {
40 0 : pluginModulesRepo()->refresh();
41 0 : }
42 :
43 0 : void VstFxResolver::clearAllFx()
44 : {
45 0 : instancesRegister()->unregisterAllFx();
46 :
47 0 : AbstractFxResolver::clearAllFx();
48 0 : }
49 :
50 0 : IFxProcessorPtr VstFxResolver::createMasterFx(const AudioFxParams& fxParams, const audio::OutputSpec& outputSpec) const
51 : {
52 0 : if (!pluginModulesRepo()->exists(fxParams.resourceMeta.id)) {
53 0 : return nullptr;
54 : }
55 :
56 0 : IVstPluginInstancePtr pluginPtr = instancesRegister()->makeAndRegisterMasterFxPlugin(fxParams.resourceMeta.id, fxParams.chainOrder);
57 :
58 0 : VstFxPtr fx = std::make_shared<VstFxProcessor>(pluginPtr, fxParams);
59 0 : fx->init(outputSpec);
60 :
61 0 : return fx;
62 0 : }
63 :
64 0 : IFxProcessorPtr VstFxResolver::createTrackFx(const TrackId trackId, const AudioFxParams& fxParams,
65 : const audio::OutputSpec& outputSpec) const
66 : {
67 0 : if (!pluginModulesRepo()->exists(fxParams.resourceMeta.id)) {
68 0 : LOGE() << "Unable to create VST plugin"
69 0 : << ", pluginId: " << fxParams.resourceMeta.id
70 0 : << ", trackId: " << trackId;
71 0 : return nullptr;
72 : }
73 :
74 0 : IVstPluginInstancePtr pluginPtr = instancesRegister()->makeAndRegisterFxPlugin(fxParams.resourceMeta.id, trackId, fxParams.chainOrder);
75 :
76 0 : VstFxPtr fx = std::make_shared<VstFxProcessor>(pluginPtr, fxParams);
77 0 : fx->init(outputSpec);
78 :
79 0 : return fx;
80 0 : }
81 :
82 0 : void VstFxResolver::removeMasterFx(const AudioResourceId& resoureId, AudioFxChainOrder chainOrder)
83 : {
84 0 : instancesRegister()->unregisterMasterFxPlugin(resoureId, chainOrder);
85 0 : }
86 :
87 0 : void VstFxResolver::removeTrackFx(const TrackId trackId, const AudioResourceId& resoureId, AudioFxChainOrder chainOrder)
88 : {
89 0 : instancesRegister()->unregisterFxPlugin(resoureId, trackId, chainOrder);
90 0 : }
|