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 : #include "audioengineconfiguration.h"
23 :
24 : #include "audio/common/audiosanitizer.h"
25 : #include "audio/common/soundfonttypes.h"
26 : #include "audio/common/rpc/rpcpacker.h"
27 :
28 : #include "log.h"
29 :
30 : using namespace muse;
31 : using namespace muse::audio;
32 : using namespace muse::audio::engine;
33 : using namespace muse::audio::rpc;
34 :
35 : static const AudioResourceId DEFAULT_SOUND_FONT_NAME = "MS Basic";
36 : static const AudioResourceAttributes DEFAULT_AUDIO_RESOURCE_ATTRIBUTES = {
37 : { PLAYBACK_SETUP_DATA_ATTRIBUTE, muse::mpe::GENERIC_SETUP_DATA_STRING },
38 : { synth::SOUNDFONT_NAME_ATTRIBUTE, String::fromStdString(DEFAULT_SOUND_FONT_NAME) } };
39 :
40 : static const AudioResourceMeta DEFAULT_AUDIO_RESOURCE_META = {
41 : DEFAULT_SOUND_FONT_NAME,
42 : "Fluid",
43 : DEFAULT_AUDIO_RESOURCE_ATTRIBUTES,
44 : std::string(FLUID_SOUNDFONT_TYPE_NAME) };
45 :
46 0 : void AudioEngineConfiguration::setConfig(const AudioEngineConfig& conf)
47 : {
48 : ONLY_AUDIO_ENGINE_THREAD;
49 :
50 0 : if (conf.autoProcessOnlineSoundsInBackground != m_conf.autoProcessOnlineSoundsInBackground) {
51 0 : m_conf.autoProcessOnlineSoundsInBackground = conf.autoProcessOnlineSoundsInBackground;
52 0 : m_autoProcessOnlineSoundsInBackgroundChanged.send(m_conf.autoProcessOnlineSoundsInBackground);
53 : }
54 :
55 0 : setIsLazyProcessingOfOnlineSoundsEnabled(conf.isLazyProcessingOfOnlineSoundsEnabled);
56 :
57 0 : if (conf.useSoundFontLowPassFilter != m_conf.useSoundFontLowPassFilter) {
58 0 : m_conf.useSoundFontLowPassFilter = conf.useSoundFontLowPassFilter;
59 0 : m_useSoundFontLowPassFilterChanged.send(m_conf.useSoundFontLowPassFilter);
60 : }
61 0 : }
62 :
63 0 : bool AudioEngineConfiguration::autoProcessOnlineSoundsInBackground() const
64 : {
65 0 : return m_conf.autoProcessOnlineSoundsInBackground;
66 : }
67 :
68 0 : async::Channel<bool> AudioEngineConfiguration::autoProcessOnlineSoundsInBackgroundChanged() const
69 : {
70 0 : return m_autoProcessOnlineSoundsInBackgroundChanged;
71 : }
72 :
73 0 : void AudioEngineConfiguration::setIsLazyProcessingOfOnlineSoundsEnabled(bool enabled)
74 : {
75 0 : if (m_conf.isLazyProcessingOfOnlineSoundsEnabled == enabled) {
76 0 : return;
77 : }
78 :
79 0 : m_conf.isLazyProcessingOfOnlineSoundsEnabled = enabled;
80 0 : m_isLazyProcessingOfOnlineSoundsEnabledChanged.send(enabled);
81 : }
82 :
83 0 : bool AudioEngineConfiguration::isLazyProcessingOfOnlineSoundsEnabled() const
84 : {
85 0 : return m_conf.isLazyProcessingOfOnlineSoundsEnabled;
86 : }
87 :
88 0 : async::Channel<bool> AudioEngineConfiguration::isLazyProcessingOfOnlineSoundsEnabledChanged() const
89 : {
90 0 : return m_isLazyProcessingOfOnlineSoundsEnabledChanged;
91 : }
92 :
93 0 : bool AudioEngineConfiguration::useSoundFontLowPassFilter() const
94 : {
95 0 : return m_conf.useSoundFontLowPassFilter;
96 : }
97 :
98 0 : async::Channel<bool> AudioEngineConfiguration::useSoundFontLowPassFilterChanged() const
99 : {
100 0 : return m_useSoundFontLowPassFilterChanged;
101 : }
102 :
103 0 : AudioInputParams AudioEngineConfiguration::defaultAudioInputParams() const
104 : {
105 0 : AudioInputParams result;
106 0 : result.resourceMeta = DEFAULT_AUDIO_RESOURCE_META;
107 :
108 0 : return result;
109 0 : }
|