LMMS
Loading...
Searching...
No Matches
AudioBusHandle.h
Go to the documentation of this file.
1/*
2 * AudioBusHandle.h - ThreadableJob between PlayHandle and MixerChannel
3 *
4 * Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2025 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
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 GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_AUDIO_BUS_HANDLE_H
27#define LMMS_AUDIO_BUS_HANDLE_H
28
29#include <memory>
30#include <QString>
31#include <QMutex>
32
33#include "AudioBuffer.h"
34#include "PlayHandle.h"
35
36namespace lmms
37{
38
39class EffectChain;
40class FloatModel;
41class BoolModel;
42
55{
56public:
57 AudioBusHandle(const QString& name, bool hasEffectChain = true,
58 FloatModel* volumeModel = nullptr, FloatModel* panningModel = nullptr,
59 BoolModel* mutedModel = nullptr);
60 virtual ~AudioBusHandle();
61
62 // indicate whether JACK & Co should provide output-buffer at ext. port
63 bool extOutputEnabled() const { return m_extOutputEnabled; }
64 void setExtOutputEnabled(bool enabled);
65
66 // next mixer-channel after this audio-bus-handle
67 // (-1 = none 0 = master)
69 void setNextMixerChannel(const mix_ch_t chnl) { m_nextMixerChannel = chnl; }
70
71 const QString& name() const { return m_name; }
72 void setName(const QString& newName);
73
74 EffectChain* effects() { return m_effects.get(); }
75 bool processEffects();
76
77 // ThreadableJob stuff
78 void doProcessing() override;
79 bool requiresProcessing() const override { return true; }
80
81 void addPlayHandle(PlayHandle* handle);
82 void removePlayHandle(PlayHandle* handle);
83
85 bool isCorrupted() const { return m_corrupted.load(std::memory_order_relaxed); }
86
87private:
88 volatile bool m_bufferUsage;
89
91
94
95 QString m_name;
96
97 std::unique_ptr<EffectChain> m_effects;
98
101
105
106 std::atomic<bool> m_corrupted = false;
107
108 friend class AudioEngine;
110};
111
112} // namespace lmms
113
114#endif // LMMS_AUDIO_BUS_HANDLE_H
Definition AudioBuffer.h:79
void setNextMixerChannel(const mix_ch_t chnl)
Definition AudioBusHandle.h:69
QMutex m_playHandleLock
Definition AudioBusHandle.h:100
virtual ~AudioBusHandle()
Definition AudioBusHandle.cpp:62
friend class AudioEngine
Definition AudioBusHandle.h:108
BoolModel * m_mutedModel
Definition AudioBusHandle.h:104
bool processEffects()
Definition AudioBusHandle.cpp:99
AudioBuffer m_buffer
Definition AudioBusHandle.h:90
std::unique_ptr< EffectChain > m_effects
Definition AudioBusHandle.h:97
EffectChain * effects()
Definition AudioBusHandle.h:74
const QString & name() const
Definition AudioBusHandle.h:71
bool m_extOutputEnabled
Definition AudioBusHandle.h:92
void setExtOutputEnabled(bool enabled)
Definition AudioBusHandle.cpp:71
FloatModel * m_volumeModel
Definition AudioBusHandle.h:102
QString m_name
Definition AudioBusHandle.h:95
void doProcessing() override
Definition AudioBusHandle.cpp:110
void addPlayHandle(PlayHandle *handle)
Definition AudioBusHandle.cpp:253
PlayHandleList m_playHandles
Definition AudioBusHandle.h:99
bool isCorrupted() const
Definition AudioBusHandle.h:85
FloatModel * m_panningModel
Definition AudioBusHandle.h:103
volatile bool m_bufferUsage
Definition AudioBusHandle.h:88
void removePlayHandle(PlayHandle *handle)
Definition AudioBusHandle.cpp:260
void setName(const QString &newName)
Definition AudioBusHandle.cpp:90
bool requiresProcessing() const override
Definition AudioBusHandle.h:79
mix_ch_t nextMixerChannel() const
Definition AudioBusHandle.h:68
mix_ch_t m_nextMixerChannel
Definition AudioBusHandle.h:93
AudioBusHandle(const QString &name, bool hasEffectChain=true, FloatModel *volumeModel=nullptr, FloatModel *panningModel=nullptr, BoolModel *mutedModel=nullptr)
Definition AudioBusHandle.cpp:40
std::atomic< bool > m_corrupted
Definition AudioBusHandle.h:106
bool extOutputEnabled() const
Definition AudioBusHandle.h:63
friend class AudioEngineWorkerThread
Definition AudioBusHandle.h:109
Definition AutomatableModel.h:497
Definition EffectChain.h:48
Definition AutomatableModel.h:463
Definition PlayHandle.h:47
ThreadableJob()
Definition ThreadableJob.h:47
Definition AudioAlsa.cpp:35
QList< PlayHandle * > PlayHandleList
Definition PlayHandle.h:162
std::uint16_t mix_ch_t
Definition LmmsTypes.h:47