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) 2026 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 "fxnode.h"
24 :
25 : using namespace muse;
26 : using namespace muse::audio;
27 : using namespace muse::audio::engine;
28 :
29 0 : FxNode::FxNode(IFxProcessorPtr fxProcessor, PlayheadPositionPtr playheadPosition)
30 0 : : m_fxProcessor(fxProcessor), m_playheadPosition(playheadPosition)
31 : {
32 0 : assert(m_fxProcessor && "FxNode requires a non-null IFxProcessor");
33 :
34 0 : setName(std::string("Fx[") + m_fxProcessor->name() + "]");
35 0 : }
36 :
37 0 : void FxNode::setPlayheadPosition(PlayheadPositionPtr playheadPosition)
38 : {
39 0 : m_playheadPosition = playheadPosition;
40 0 : }
41 :
42 0 : void FxNode::onModeChanged(const ProcessMode mode)
43 : {
44 0 : m_fxProcessor->setMode(mode);
45 0 : }
46 :
47 0 : const AudioFxParams& FxNode::params() const
48 : {
49 0 : return m_fxProcessor->params();
50 : }
51 :
52 0 : async::Channel<audio::AudioFxParams> FxNode::paramsChanged() const
53 : {
54 0 : return m_fxProcessor->paramsChanged();
55 : }
56 :
57 0 : bool FxNode::shouldProcessDuringSilence() const
58 : {
59 0 : return m_fxProcessor->shouldProcessDuringSilence();
60 : }
61 :
62 0 : void FxNode::onOutputSpecChanged(const OutputSpec& spec)
63 : {
64 0 : m_fxProcessor->setOutputSpec(spec);
65 0 : }
66 :
67 0 : void FxNode::doSelfProcess(float* buffer, samples_t samplesPerChannel)
68 : {
69 0 : samples_t pos = m_playheadPosition ? m_playheadPosition->currentPosition().samples() : 0;
70 0 : m_fxProcessor->process(buffer, samplesPerChannel, pos);
71 0 : }
|