LCOV - code coverage report
Current view: top level - muse/framework/musesampler/internal - musesamplersequencer.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 3 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              : #pragma once
      23              : 
      24              : #include "audio/engine/internal/abstracteventsequencer.h"
      25              : #include "imusesamplertracks.h"
      26              : 
      27              : #include "internal/apitypes.h"
      28              : #include "internal/libhandler.h"
      29              : 
      30              : namespace muse::musesampler {
      31              : class MuseSamplerSequencer : public audio::engine::AbstractEventSequencer<mpe::NoteEvent, AuditionStartNoteEvent, AuditionStopNoteEvent,
      32              :                                                                           AuditionCCEvent>
      33              : {
      34              : public:
      35              :     void init(MuseSamplerLibHandlerPtr samplerLib, ms_MuseSampler sampler, IMuseSamplerTracks* tracks, std::string&& defaultPresetCode);
      36              : 
      37              : private:
      38              :     void updateMainStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::DynamicAutomationLayers& dynamics) override;
      39              :     void updateOffStreamEvents(const mpe::PlaybackEventsMap& events) override;
      40              : 
      41              :     void clearAllTracks();
      42              :     void finalizeAllTracks();
      43              : 
      44              :     ms_Track findOrCreateTrack(mpe::layer_idx_t layerIdx);
      45              :     ms_Track findTrack(mpe::layer_idx_t layerIdx) const;
      46              : 
      47              :     const TrackList& allTracks() const;
      48              : 
      49              :     void loadEvents(const mpe::PlaybackEventsMap& changes);
      50              :     void loadDynamicEvents(const mpe::DynamicAutomationLayers& changes);
      51              : 
      52              :     void addNoteEvent(const mpe::NoteEvent& noteEvent);
      53              :     void addPedalEvent(const mpe::ArticulationMeta& meta, ms_Track track);
      54              :     void addTextArticulationEvent(const mpe::TextArticulationEvent& event, long long startUs);
      55              :     void addSoundPresetEvent(const mpe::SoundPresetChangeEvent& event, long long positionUs);
      56              :     void addSyllableEvent(const mpe::SyllableEvent& event, long long positionUs);
      57              :     void addPitchBends(const mpe::NoteEvent& noteEvent, long long noteEventId, ms_Track track);
      58              :     void addVibrato(const mpe::NoteEvent& noteEvent, long long noteEventId, ms_Track track);
      59              : 
      60              :     void addAuditionNoteEvent(const mpe::NoteEvent& noteEvent);
      61              :     void addAuditionPedalEvent(const mpe::ArticulationMeta& meta, ms_Track track);
      62              :     void addAuditionCCEvent(const mpe::ControllerChangeEvent& event, long long positionUs);
      63              : 
      64              :     void pitchAndTuning(const mpe::pitch_level_t nominalPitch, int& pitch, int& centsOffset) const;
      65              :     int pitchLevelToCents(const mpe::pitch_level_t pitchLevel) const;
      66              :     double dynamicLevelRatio(const mpe::dynamic_level_t level) const;
      67              : 
      68              :     void parseArticulations(const mpe::ArticulationMap& articulations, ms_NoteArticulation& articulations1,
      69              :                             ms_NoteArticulation2& articulations2, ms_NoteHead& notehead) const;
      70              : 
      71              :     struct AuditionParams {
      72              :         std::string presets;
      73              :         std::string textArticulation;
      74              :         std::string syllable;
      75              :         bool textArticulationStartsAtNote = false;
      76              :         bool syllableStartsAtNote = false;
      77              : 
      78            0 :         void clear()
      79              :         {
      80            0 :             *this = AuditionParams();
      81            0 :         }
      82              :     };
      83              : 
      84              :     void parseAuditionParams(const mpe::PlaybackEvent& event, AuditionParams& out) const;
      85              : 
      86              :     MuseSamplerLibHandlerPtr m_samplerLib = nullptr;
      87              :     ms_MuseSampler m_sampler = nullptr;
      88              :     IMuseSamplerTracks* m_tracks = nullptr;
      89              : 
      90              :     std::unordered_map<mpe::layer_idx_t, track_idx_t> m_layerIdxToTrackIdx;
      91              :     std::unordered_map<ms_Track, std::map<long long /*startUs*/, ms_PresetChange> > m_presetChangesByTrack;
      92              : 
      93              :     std::string m_defaultPresetCode;
      94              :     AuditionParams m_auditionParamsCache;
      95              : };
      96              : }
        

Generated by: LCOV version 2.0-1