LCOV - code coverage report
Current view: top level - muse/framework/vst/internal - vstinstancesregister.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 8 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              : 
      23              : #pragma once
      24              : 
      25              : #include <map>
      26              : #include <mutex>
      27              : 
      28              : #include "../ivstinstancesregister.h"
      29              : #include "async/asyncable.h"
      30              : 
      31              : namespace muse::vst {
      32              : class VstInstancesRegister : public IVstInstancesRegister, public async::Asyncable
      33              : {
      34              : public:
      35              :     // make
      36              :     IVstPluginInstancePtr makeAndRegisterInstrPlugin(const muse::audio::AudioResourceId& resourceId,
      37              :                                                      const muse::audio::TrackId trackId) override;
      38              : 
      39              :     IVstPluginInstancePtr makeAndRegisterFxPlugin(const muse::audio::AudioResourceId& resourceId, const muse::audio::TrackId trackId,
      40              :                                                   const muse::audio::AudioFxChainOrder chainOrder) override;
      41              : 
      42              :     IVstPluginInstancePtr makeAndRegisterMasterFxPlugin(const muse::audio::AudioResourceId& resourceId,
      43              :                                                         const muse::audio::AudioFxChainOrder chainOrder) override;
      44              : 
      45              :     // register
      46              :     void registerInstrPlugin(const muse::audio::TrackId trackId, IVstPluginInstancePtr instance) override;
      47              : 
      48              :     void registerFxPlugin(const muse::audio::TrackId trackId, const muse::audio::AudioFxChainOrder chainOrder,
      49              :                           IVstPluginInstancePtr instance) override;
      50              : 
      51              :     void registerMasterFxPlugin(const muse::audio::AudioFxChainOrder chainOrder, IVstPluginInstancePtr instance) override;
      52              : 
      53              :     // get
      54              :     IVstPluginInstancePtr instanceById(const VstPluginInstanceId id) const override;
      55              :     IVstPluginInstancePtr instrumentPlugin(const muse::audio::AudioResourceId& resourceId,
      56              :                                            const muse::audio::TrackId trackId) const override;
      57              :     IVstPluginInstancePtr fxPlugin(const muse::audio::AudioResourceId& resourceId, const muse::audio::TrackId trackId,
      58              :                                    const muse::audio::AudioFxChainOrder chainOrder) const override;
      59              :     IVstPluginInstancePtr masterFxPlugin(const muse::audio::AudioResourceId& resourceId,
      60              :                                          const muse::audio::AudioFxChainOrder chainOrder) const override;
      61              : 
      62              :     // unregister
      63              :     void unregisterById(const VstPluginInstanceId id) override;
      64              :     void unregisterInstrPlugin(const muse::audio::AudioResourceId& resourceId, const muse::audio::TrackId trackId) override;
      65              :     void unregisterFxPlugin(const muse::audio::AudioResourceId& resourceId, const muse::audio::TrackId trackId,
      66              :                             const muse::audio::AudioFxChainOrder chainOrder) override;
      67              :     void unregisterMasterFxPlugin(const muse::audio::AudioResourceId& resourceId, const muse::audio::AudioFxChainOrder chainOrder) override;
      68              : 
      69              :     void unregisterAllInstrPlugin() override;
      70              :     void unregisterAllFx() override;
      71              : 
      72              : private:
      73              :     mutable std::mutex m_mutex;
      74              : 
      75              :     enum class Type {
      76              :         Undefined = 0,
      77              :         Instrument,
      78              :         Effect
      79              :     };
      80              : 
      81              :     struct Key {
      82              :         Type type = Type::Undefined;
      83              :         muse::audio::AudioResourceId resourceId;
      84              :         muse::audio::TrackId trackId = -1;
      85              :         muse::audio::AudioFxChainOrder chainOrder = 0;
      86              : 
      87              :         inline bool operator ==(const Key& k) const
      88              :         {
      89              :             return type == k.type && trackId == k.trackId && resourceId == k.resourceId && chainOrder == k.chainOrder;
      90              :         }
      91              : 
      92            0 :         inline bool operator <(const Key& k) const
      93              :         {
      94            0 :             if (type != k.type) {
      95            0 :                 return type < k.type;
      96              :             }
      97              : 
      98            0 :             if (trackId != k.trackId) {
      99            0 :                 return trackId < k.trackId;
     100              :             }
     101              : 
     102            0 :             if (resourceId != k.resourceId) {
     103            0 :                 return resourceId < k.resourceId;
     104              :             }
     105              : 
     106            0 :             return chainOrder < k.chainOrder;
     107              :         }
     108              :     };
     109              : 
     110              :     std::map<Key, IVstPluginInstancePtr> m_instances;
     111              : };
     112              : }
        

Generated by: LCOV version 2.0-1