LCOV - code coverage report
Current view: top level - src/engraving/playback - playbacksetupdataresolver.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 55.2 % 29 16
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-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              : #include "playbacksetupdataresolver.h"
      24              : 
      25              : #include "mapping/keyboardssetupdataresolver.h"
      26              : #include "mapping/stringssetupdataresolver.h"
      27              : #include "mapping/windssetupdataresolver.h"
      28              : #include "mapping/percussionssetupdataresolver.h"
      29              : #include "mapping/voicessetupdataresolver.h"
      30              : 
      31              : #include "log.h"
      32              : 
      33              : using namespace mu::engraving;
      34              : using namespace muse::mpe;
      35              : 
      36              : static const PlaybackSetupData PIANO_SETUP_DATA = {
      37              :     SoundId::Piano, SoundCategory::Keyboards
      38              : };
      39              : 
      40           46 : void PlaybackSetupDataResolver::resolveSetupData(const Instrument* instrument, PlaybackSetupData& result) const
      41              : {
      42           46 :     if (!instrument->soundId().empty()) {
      43            0 :         result = PlaybackSetupData::fromString(instrument->soundId());
      44            0 :         result.supportsSingleNoteDynamics = instrument->singleNoteDynamics();
      45            0 :         result.musicXmlSoundId = std::make_optional(instrument->musicXmlId().toStdString());
      46            0 :         return;
      47              :     }
      48              : 
      49           46 :     if (KeyboardsSetupDataResolver::resolve(instrument, result)) {
      50            5 :         return;
      51              :     }
      52              : 
      53           41 :     if (StringsSetupDataResolver::resolve(instrument, result)) {
      54           20 :         return;
      55              :     }
      56              : 
      57           21 :     if (WindsSetupDataResolver::resolve(instrument, result)) {
      58           10 :         return;
      59              :     }
      60              : 
      61           11 :     if (PercussionsSetupDataResolver::resolve(instrument, result)) {
      62            8 :         return;
      63              :     }
      64              : 
      65            3 :     if (VoicesSetupDataResolver::resolve(instrument, result)) {
      66            3 :         return;
      67              :     }
      68              : 
      69            0 :     LOGW() << "Unable to resolve setup data for instrument, id: " << instrument->id()
      70            0 :            << ", family: " << instrument->family() << "; fallback to piano";
      71              : 
      72            0 :     result = PIANO_SETUP_DATA;
      73              : }
      74              : 
      75            0 : void PlaybackSetupDataResolver::resolveChordSymbolsSetupData(const Instrument* instrument, PlaybackSetupData& result) const
      76              : {
      77            0 :     if (instrument->hasStrings()) {
      78              :         static const PlaybackSetupData GUITAR_SETUP_DATA = {
      79              :             SoundId::Guitar, SoundCategory::Strings, { SoundSubCategory::Acoustic,
      80              :                                                        SoundSubCategory::Nylon,
      81              :                                                        SoundSubCategory::Plucked }
      82            0 :         };
      83              : 
      84            0 :         result = GUITAR_SETUP_DATA;
      85              :     } else {
      86            0 :         result = PIANO_SETUP_DATA;
      87              :     }
      88            0 : }
      89              : 
      90           31 : void PlaybackSetupDataResolver::resolveMetronomeSetupData(PlaybackSetupData& result) const
      91              : {
      92              :     static const PlaybackSetupData METRONOME_SETUP_DATA = {
      93              :         SoundId::Block, SoundCategory::Percussions, { SoundSubCategory::Wooden }
      94           33 :     };
      95              : 
      96           31 :     result = METRONOME_SETUP_DATA;
      97           31 : }
        

Generated by: LCOV version 2.0-1