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 : #pragma once
24 :
25 : #include <memory>
26 :
27 : #include "modularity/imoduleinterface.h"
28 : #include "modularity/ioc.h"
29 :
30 : #include "audio/common/audiotypes.h"
31 :
32 : #include "isynthesizer.h"
33 :
34 : namespace muse::audio::synth {
35 : class ISynthResolver : MODULE_GLOBAL_INTERFACE
36 : {
37 0 : INTERFACE_ID(ISynthResolver)
38 :
39 : public:
40 0 : virtual ~ISynthResolver() = default;
41 :
42 : class IResolver
43 : {
44 : public:
45 0 : virtual ~IResolver() = default;
46 :
47 : virtual ISynthesizerPtr resolveSynth(const TrackId trackId, const AudioInputParams& params, const OutputSpec& outputSpec) const = 0;
48 : virtual bool hasCompatibleResources(const PlaybackSetupData& setup) const = 0;
49 : virtual AudioResourceMetaList resolveResources() const = 0;
50 : virtual SoundPresetList resolveSoundPresets(const AudioResourceMeta& resourceMeta) const = 0;
51 : virtual void refresh() = 0;
52 : virtual void clearSources() = 0;
53 : };
54 : using IResolverPtr = std::shared_ptr<IResolver>;
55 :
56 : virtual void init(const AudioInputParams& defaultInputParams, const audio::OutputSpec& defaultOutputSpec) = 0;
57 :
58 : virtual ISynthesizerPtr resolveSynth(const TrackId trackId, const AudioInputParams& params, const OutputSpec& spec,
59 : const PlaybackSetupData& setupData) const = 0;
60 : virtual ISynthesizerPtr resolveDefaultSynth(const TrackId trackId) const = 0;
61 : virtual AudioInputParams resolveDefaultInputParams() const = 0;
62 : virtual AudioResourceMetaList resolveAvailableResources() const = 0;
63 : virtual SoundPresetList resolveAvailableSoundPresets(const AudioResourceMeta& resourceMeta) const = 0;
64 : virtual void registerResolver(const AudioSourceType type, IResolverPtr resolver) = 0;
65 : virtual void clearSources() = 0;
66 : };
67 :
68 : using ISynthResolverPtr = std::shared_ptr<ISynthResolver>;
69 : }
|