LCOV - code coverage report
Current view: top level - muse/framework/midi/internal - midiconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 48 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 "midiconfiguration.h"
      23              : 
      24              : #include "miditypes.h"
      25              : 
      26              : #include "settings.h"
      27              : 
      28              : using namespace muse;
      29              : using namespace muse::midi;
      30              : 
      31              : static const std::string module_name("midi");
      32              : 
      33              : static const Settings::Key USE_REMOTE_CONTROL_KEY(module_name, "io/midi/useRemoteControl");
      34              : static const Settings::Key MIDI_INPUT_DEVICE_ID(module_name, "io/inputDeviceId");
      35              : static const Settings::Key MIDI_OUTPUT_DEVICE_ID(module_name, "io/outputDeviceId");
      36              : static const Settings::Key USE_MIDI20_OUTPUT_KEY(module_name, "io/midi/useMIDI20Output");
      37              : 
      38            0 : void MidiConfiguration::init()
      39              : {
      40            0 :     settings()->setDefaultValue(USE_REMOTE_CONTROL_KEY, Val(true));
      41            0 :     settings()->valueChanged(USE_REMOTE_CONTROL_KEY).onReceive(this, [this](const Val& val) {
      42            0 :         m_useRemoteControlChanged.send(val.toBool());
      43            0 :     });
      44              : 
      45            0 :     settings()->setDefaultValue(MIDI_INPUT_DEVICE_ID, Val("")); // "" makes MuseScore select the first available device
      46            0 :     settings()->valueChanged(MIDI_INPUT_DEVICE_ID).onReceive(nullptr, [this](const Val&) {
      47            0 :         m_midiInputDeviceIdChanged.notify();
      48            0 :     });
      49              : 
      50            0 :     settings()->setDefaultValue(MIDI_OUTPUT_DEVICE_ID, Val(NONE_DEVICE_ID));
      51            0 :     settings()->valueChanged(MIDI_OUTPUT_DEVICE_ID).onReceive(nullptr, [this](const Val&) {
      52            0 :         m_midiOutputDeviceIdChanged.notify();
      53            0 :     });
      54              : 
      55            0 :     settings()->setDefaultValue(USE_MIDI20_OUTPUT_KEY, Val(true));
      56            0 :     settings()->valueChanged(USE_MIDI20_OUTPUT_KEY).onReceive(this, [this](const Val& val) {
      57            0 :         m_useMIDI20OutputChanged.send(val.toBool());
      58            0 :     });
      59            0 : }
      60              : 
      61            0 : bool MidiConfiguration::midiPortIsAvalaible() const
      62              : {
      63            0 :     return true;
      64              : }
      65              : 
      66            0 : bool MidiConfiguration::useRemoteControl() const
      67              : {
      68            0 :     return settings()->value(USE_REMOTE_CONTROL_KEY).toBool();
      69              : }
      70              : 
      71            0 : void MidiConfiguration::setUseRemoteControl(bool value)
      72              : {
      73            0 :     settings()->setSharedValue(USE_REMOTE_CONTROL_KEY, Val(value));
      74            0 : }
      75              : 
      76            0 : async::Channel<bool> MidiConfiguration::useRemoteControlChanged() const
      77              : {
      78            0 :     return m_useRemoteControlChanged;
      79              : }
      80              : 
      81            0 : MidiDeviceID MidiConfiguration::midiInputDeviceId() const
      82              : {
      83            0 :     return settings()->value(MIDI_INPUT_DEVICE_ID).toString();
      84              : }
      85              : 
      86            0 : void MidiConfiguration::setMidiInputDeviceId(const MidiDeviceID& deviceId)
      87              : {
      88            0 :     settings()->setSharedValue(MIDI_INPUT_DEVICE_ID, Val(deviceId));
      89            0 : }
      90              : 
      91            0 : async::Notification MidiConfiguration::midiInputDeviceIdChanged() const
      92              : {
      93            0 :     return m_midiInputDeviceIdChanged;
      94              : }
      95              : 
      96            0 : MidiDeviceID MidiConfiguration::midiOutputDeviceId() const
      97              : {
      98            0 :     return settings()->value(MIDI_OUTPUT_DEVICE_ID).toString();
      99              : }
     100              : 
     101            0 : void MidiConfiguration::setMidiOutputDeviceId(const MidiDeviceID& deviceId)
     102              : {
     103            0 :     settings()->setSharedValue(MIDI_OUTPUT_DEVICE_ID, Val(deviceId));
     104            0 : }
     105              : 
     106            0 : async::Notification MidiConfiguration::midiOutputDeviceIdChanged() const
     107              : {
     108            0 :     return m_midiOutputDeviceIdChanged;
     109              : }
     110              : 
     111            0 : bool MidiConfiguration::useMIDI20Output() const
     112              : {
     113            0 :     return settings()->value(USE_MIDI20_OUTPUT_KEY).toBool();
     114              : }
     115              : 
     116            0 : void MidiConfiguration::setUseMIDI20Output(bool use)
     117              : {
     118            0 :     settings()->setSharedValue(USE_MIDI20_OUTPUT_KEY, Val(use));
     119            0 : }
     120              : 
     121            0 : async::Channel<bool> MidiConfiguration::useMIDI20OutputChanged() const
     122              : {
     123            0 :     return m_useMIDI20OutputChanged;
     124              : }
        

Generated by: LCOV version 2.0-1