LCOV - code coverage report
Current view: top level - muse/framework/vst - vstmodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 49 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) 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              : #include "vstmodule.h"
      23              : 
      24              : #include "modularity/ioc.h"
      25              : #include "audio/engine/isynthresolver.h"
      26              : #include "audio/engine/ifxresolver.h"
      27              : 
      28              : #include "audioplugins/iaudiopluginsscannerregister.h"
      29              : #include "audioplugins/iaudiopluginmetareaderregister.h"
      30              : 
      31              : #include "rcommand/icommandsregister.h"
      32              : #include "rcommand/icommandsstate.h"
      33              : 
      34              : #include "internal/vstconfiguration.h"
      35              : #include "internal/vstinstancesregister.h"
      36              : #include "internal/vstmodulesrepository.h"
      37              : #include "internal/synth/vstiresolver.h"
      38              : #include "internal/fx/vstfxresolver.h"
      39              : #include "internal/vstpluginsscanner.h"
      40              : #include "internal/vstpluginmetareader.h"
      41              : #include "internal/vstactionscontroller.h"
      42              : #include "internal/vstcommandsregister.h"
      43              : #include "internal/vstcommandsstate.h"
      44              : 
      45              : using namespace muse::vst;
      46              : using namespace muse::modularity;
      47              : using namespace muse::audio::synth;
      48              : using namespace muse::audio::fx;
      49              : using namespace muse::audio;
      50              : using namespace muse::audioplugins;
      51              : 
      52              : static const std::string mname("vst");
      53              : 
      54            0 : std::string VSTModule::moduleName() const
      55              : {
      56            0 :     return mname;
      57              : }
      58              : 
      59            0 : void VSTModule::registerExports()
      60              : {
      61            0 :     m_configuration = std::make_shared<VstConfiguration>();
      62            0 :     m_pluginModulesRepo = std::make_shared<VstModulesRepository>();
      63            0 :     m_pluginInstancesRegister = std::make_shared<VstInstancesRegister>();
      64              : 
      65            0 :     globalIoc()->registerExport<IVstConfiguration>(moduleName(), m_configuration);
      66            0 :     globalIoc()->registerExport<IVstModulesRepository>(moduleName(), m_pluginModulesRepo);
      67            0 :     globalIoc()->registerExport<IVstInstancesRegister>(moduleName(), m_pluginInstancesRegister);
      68            0 : }
      69              : 
      70            0 : void VSTModule::resolveImports()
      71              : {
      72            0 :     auto synthResolver = globalIoc()->resolve<ISynthResolver>(moduleName());
      73            0 :     if (synthResolver) {
      74            0 :         synthResolver->registerResolver(AudioSourceType::Vsti, std::make_shared<VstiResolver>());
      75              :     }
      76              : 
      77            0 :     auto fxResolver = globalIoc()->resolve<IFxResolver>(moduleName());
      78            0 :     if (fxResolver) {
      79            0 :         fxResolver->registerResolver(AudioFxType::VstFx, std::make_shared<VstFxResolver>());
      80              :     }
      81              : 
      82            0 :     auto scannerRegister = globalIoc()->resolve<IAudioPluginsScannerRegister>(moduleName());
      83            0 :     if (scannerRegister) {
      84            0 :         scannerRegister->registerScanner(std::make_shared<VstPluginsScanner>());
      85              :     }
      86              : 
      87            0 :     auto metaReaderRegister = globalIoc()->resolve<IAudioPluginMetaReaderRegister>(moduleName());
      88            0 :     if (metaReaderRegister) {
      89            0 :         metaReaderRegister->registerReader(std::make_shared<VstPluginMetaReader>());
      90              :     }
      91              : 
      92            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
      93            0 :     if (cr) {
      94            0 :         cr->reg(std::make_shared<VstCommandsRegister>());
      95              :     }
      96            0 : }
      97              : 
      98            0 : void VSTModule::onInit(const IApplication::RunMode&)
      99              : {
     100            0 :     m_configuration->init();
     101            0 :     m_pluginModulesRepo->init();
     102            0 : }
     103              : 
     104            0 : void VSTModule::onDeinit()
     105              : {
     106            0 :     m_pluginModulesRepo->deInit();
     107            0 : }
     108              : 
     109            0 : muse::modularity::IContextSetup* VSTModule::newContext(const muse::modularity::ContextPtr& ctx) const
     110              : {
     111            0 :     return new VSTContext(ctx);
     112              : }
     113              : 
     114            0 : void VSTContext::registerExports()
     115              : {
     116              :     //! NOTE Now we can switch which view to use in runtime.
     117              :     //! switches the action controller, so registration is there now.
     118              :     //! as soon as the new view is stabilized, we need to remove the old one and do as usual
     119              : 
     120              :     // auto ir = globalIoc()->resolve<IInteractiveUriRegister>(mname);
     121              :     // if (ir) {
     122              :     //     ir->registerWidgetUri<VstViewDialog>(Uri("muse://vst/editor"));
     123              :     //     ir->registerQmlUri(Uri("muse://vst/editor"), "Muse.Vst", "VstEditorDialog");
     124              :     // }
     125              : 
     126            0 :     m_actionsController = std::make_shared<VstActionsController>(iocContext());
     127            0 : }
     128              : 
     129            0 : void VSTContext::resolveImports()
     130              : {
     131            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
     132            0 :     if (cs) {
     133            0 :         cs->reg(std::make_shared<VstCommandsState>(iocContext()));
     134              :     }
     135            0 : }
     136              : 
     137            0 : void VSTContext::onInit(const IApplication::RunMode& mode)
     138              : {
     139            0 :     if (mode == IApplication::RunMode::GuiApp) {
     140            0 :         m_actionsController->init();
     141            0 :         m_actionsController->setupUsedView();
     142              :     }
     143            0 : }
        

Generated by: LCOV version 2.0-1