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) 2025 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 <string>
26 :
27 : #include "global/async/channel.h"
28 : #include "global/async/notification.h"
29 :
30 : #include "audio/common/audiotypes.h"
31 : #include "audio/common/timeposition.h"
32 :
33 : namespace muse::audio::synth {
34 : class ISynthesizer
35 : {
36 : public:
37 0 : virtual ~ISynthesizer() = default;
38 :
39 : virtual std::string name() const = 0;
40 : virtual AudioSourceType type() const = 0;
41 : virtual bool isValid() const = 0;
42 :
43 : virtual void setMode(const ProcessMode mode) = 0;
44 : virtual ProcessMode mode() const = 0;
45 :
46 : virtual void setOutputSpec(const OutputSpec& spec) = 0;
47 :
48 : virtual void setup(const mpe::PlaybackData& playbackData) = 0;
49 : virtual const mpe::PlaybackData& playbackData() const = 0;
50 :
51 : virtual const audio::AudioInputParams& params() const = 0;
52 : virtual async::Channel<audio::AudioInputParams> paramsChanged() const = 0;
53 :
54 : virtual TimePosition playbackPosition() const = 0;
55 : virtual void setPlaybackPosition(const TimePosition& position) = 0;
56 :
57 : virtual void prepareToPlay() = 0;
58 : virtual bool readyToPlay() const = 0;
59 : virtual async::Notification readyToPlayChanged() const = 0;
60 :
61 : virtual void flushSound() = 0;
62 :
63 : virtual bool hasPendingChunks() const = 0;
64 : virtual void processInput() = 0;
65 : virtual InputProcessingProgress inputProcessingProgress() const = 0;
66 :
67 : virtual void clearCache() = 0;
68 :
69 : virtual samples_t process(float* buffer, samples_t samplesPerChannel) = 0;
70 : };
71 :
72 : using ISynthesizerPtr = std::shared_ptr<ISynthesizer>;
73 : }
|