LCOV - code coverage report
Current view: top level - muse/framework/vst/internal/fx - vstfxprocessor.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 54 0
Test Date: 2026-11-05 04:07:02

            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              : #include "vstfxprocessor.h"
      24              : 
      25              : using namespace muse;
      26              : using namespace muse::vst;
      27              : using namespace muse::audio;
      28              : using namespace muse::audioplugins;
      29              : 
      30            0 : VstFxProcessor::VstFxProcessor(IVstPluginInstancePtr instance, const AudioFxParams& params)
      31            0 :     : m_pluginPtr(instance),
      32            0 :     m_vstAudioClient(std::make_unique<VstAudioClient>()),
      33            0 :     m_params(params)
      34              : {
      35            0 : }
      36              : 
      37            0 : void VstFxProcessor::init(const audio::OutputSpec& spec)
      38              : {
      39            0 :     IF_ASSERT_FAILED(spec.isValid()) {
      40            0 :         return;
      41              :     }
      42              : 
      43            0 :     m_outputSpec = spec;
      44              : 
      45            0 :     m_vstAudioClient->init(PluginType::Fx, m_pluginPtr);
      46              : 
      47            0 :     auto onPluginLoaded = [this]() {
      48            0 :         m_pluginPtr->updatePluginConfig(m_params.configuration);
      49            0 :         m_vstAudioClient->setOutputSpec(m_outputSpec);
      50            0 :         m_inited = true;
      51            0 :     };
      52              : 
      53            0 :     if (m_pluginPtr->isLoaded()) {
      54            0 :         onPluginLoaded();
      55              :     } else {
      56            0 :         m_pluginPtr->loadingCompleted().onNotify(this, onPluginLoaded);
      57              :     }
      58              : 
      59            0 :     m_pluginPtr->pluginSettingsChanged().onReceive(this, [this](const muse::audio::AudioUnitConfig& newConfig) {
      60            0 :         if (m_params.configuration == newConfig) {
      61            0 :             return;
      62              :         }
      63              : 
      64            0 :         m_params.configuration = newConfig;
      65            0 :         m_paramsChanges.send(m_params);
      66              :     });
      67              : }
      68              : 
      69            0 : AudioFxType VstFxProcessor::type() const
      70              : {
      71            0 :     return muse::audio::AudioFxType::VstFx;
      72              : }
      73              : 
      74            0 : std::string VstFxProcessor::name() const
      75              : {
      76            0 :     std::string pname;
      77            0 :     if (m_pluginPtr) {
      78            0 :         pname = m_pluginPtr->name();
      79              :     }
      80              : 
      81            0 :     return "Vst/" + pname;
      82            0 : }
      83              : 
      84            0 : const AudioFxParams& VstFxProcessor::params() const
      85              : {
      86            0 :     return m_params;
      87              : }
      88              : 
      89            0 : async::Channel<AudioFxParams> VstFxProcessor::paramsChanged() const
      90              : {
      91            0 :     return m_paramsChanges;
      92              : }
      93              : 
      94            0 : void VstFxProcessor::setOutputSpec(const audio::OutputSpec& spec)
      95              : {
      96            0 :     m_outputSpec = spec;
      97              : 
      98            0 :     if (m_inited) {
      99            0 :         m_vstAudioClient->setOutputSpec(spec);
     100              :     }
     101            0 : }
     102              : 
     103            0 : bool VstFxProcessor::active() const
     104              : {
     105            0 :     return m_params.active;
     106              : }
     107              : 
     108            0 : void VstFxProcessor::setActive(bool active)
     109              : {
     110            0 :     m_params.active = active;
     111            0 : }
     112              : 
     113            0 : void VstFxProcessor::setMode(const muse::audio::ProcessMode mode)
     114              : {
     115            0 :     m_vstAudioClient->setIsPlaying(muse::audio::isModePlaying(mode));
     116            0 : }
     117              : 
     118            0 : bool VstFxProcessor::shouldProcessDuringSilence() const
     119              : {
     120            0 :     return m_params.active && muse::contains(m_params.categories, AudioFxCategory::FxGenerator);
     121              : }
     122              : 
     123            0 : void VstFxProcessor::process(float* buffer, samples_t sampleCount, samples_t playbackPositionSamples)
     124              : {
     125            0 :     if (!buffer || !m_inited) {
     126            0 :         return;
     127              :     }
     128              : 
     129            0 :     m_vstAudioClient->process(buffer, sampleCount, playbackPositionSamples);
     130              : }
        

Generated by: LCOV version 2.0-1