LCOV - code coverage report
Current view: top level - muse/framework/audio/engine/internal/nodes - controlnode.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 34 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) 2026 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 "controlnode.h"
      24              : 
      25              : #include "../dsp/audiomathutils.h"
      26              : 
      27              : using namespace muse;
      28              : using namespace muse::audio;
      29              : using namespace muse::audio::engine;
      30              : 
      31            0 : void ControlNode::setVolume(float value)
      32              : {
      33            0 :     m_volume = value;
      34            0 :     updateChannelGains();
      35            0 : }
      36              : 
      37            0 : float ControlNode::volume() const
      38              : {
      39            0 :     return m_volume;
      40              : }
      41              : 
      42            0 : void ControlNode::setPan(float pan)
      43              : {
      44            0 :     m_pan = pan;
      45            0 :     updateChannelGains();
      46            0 : }
      47              : 
      48            0 : float ControlNode::pan() const
      49              : {
      50            0 :     return m_pan;
      51              : }
      52              : 
      53            0 : void ControlNode::setMuted(bool muted)
      54              : {
      55            0 :     setEnabled(!muted);
      56            0 : }
      57              : 
      58            0 : bool ControlNode::muted() const
      59              : {
      60            0 :     return !enabled();
      61              : }
      62              : 
      63            0 : void ControlNode::onOutputSpecChanged(const OutputSpec&)
      64              : {
      65            0 :     updateChannelGains();
      66            0 : }
      67              : 
      68            0 : void ControlNode::updateChannelGains()
      69              : {
      70            0 :     const audioch_t channelsCount = m_outputSpec.audioChannelCount;
      71            0 :     m_channelGains.resize(channelsCount);
      72            0 :     for (audioch_t audioChNum = 0; audioChNum < channelsCount; ++audioChNum) {
      73            0 :         m_channelGains[audioChNum] = dsp::balanceGain(m_pan, audioChNum) * m_volume;
      74              :     }
      75            0 : }
      76              : 
      77            0 : void ControlNode::doSelfProcess(float* buffer, samples_t samplesPerChannel)
      78              : {
      79            0 :     const audioch_t channelsCount = m_outputSpec.audioChannelCount;
      80              : 
      81            0 :     for (size_t s = 0; s < samplesPerChannel; ++s) {
      82            0 :         const size_t frameOffset = s * channelsCount;
      83            0 :         for (size_t ch = 0; ch < channelsCount; ++ch) {
      84            0 :             const size_t idx = frameOffset + ch;
      85            0 :             buffer[idx] = buffer[idx] * m_channelGains[ch];
      86              :         }
      87              :     }
      88            0 : }
        

Generated by: LCOV version 2.0-1