Mema
Memory Matrix — multi-channel audio matrix monitor and router
Loading...
Searching...
No Matches
MemaClientControlComponentBase.cpp
Go to the documentation of this file.
1/* Copyright (c) 2025, Christian Ahrens
2 *
3 * This file is part of Mema <https://github.com/ChristianAhrens/Mema>
4 *
5 * This tool is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This tool is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this tool; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
20
21#include <CustomLookAndFeel.h>
22
23
24namespace Mema
25{
26
27
32
36
41
46
47void MemaClientControlComponentBase::setIOCount(const std::pair<int, int>& ioCount)
48{
49 m_ioCount = ioCount;
50}
51
53{
54 return m_ioCount;
55}
56
57void MemaClientControlComponentBase::setInputMuteStates(const std::map<std::uint16_t, bool>& inputMuteStates)
58{
59 m_inputMuteStates = inputMuteStates;
60}
61
62const std::map<std::uint16_t, bool>& MemaClientControlComponentBase::getInputMuteStates()
63{
64 return m_inputMuteStates;
65}
66
67void MemaClientControlComponentBase::setOutputMuteStates(const std::map<std::uint16_t, bool>& outputMuteStates)
68{
69 m_outputMuteStates = outputMuteStates;
70}
71
72const std::map<std::uint16_t, bool>& MemaClientControlComponentBase::getOutputMuteStates()
73{
74 return m_outputMuteStates;
75}
76
77void MemaClientControlComponentBase::setCrosspointStates(const std::map<std::uint16_t, std::map<std::uint16_t, bool>>& crosspointStates)
78{
79 m_crosspointStates = crosspointStates;
80}
81
82const std::map<std::uint16_t, std::map<std::uint16_t, bool>>& MemaClientControlComponentBase::getCrosspointStates()
83{
84 return m_crosspointStates;
85}
86
87void MemaClientControlComponentBase::setCrosspointValues(const std::map<std::uint16_t, std::map<std::uint16_t, float>>& crosspointValues)
88{
89 //juce::String dbgStr;
90 //for (auto const& iKV : crosspointValues)
91 //{
92 // dbgStr << int(iKV.first) << " - ";
93 // for (auto const& oKV : iKV.second)
94 // dbgStr << int(oKV.first) << ":" << oKV.second << ";";
95 // dbgStr << "\n";
96 //}
97 //DBG(juce::String(__FUNCTION__) + "\n" + dbgStr);
98
99 m_crosspointValues = crosspointValues;
100}
101
102const std::map<std::uint16_t, std::map<std::uint16_t, float>>& MemaClientControlComponentBase::getCrosspointValues()
103{
104 //juce::String dbgStr;
105 //for (auto const& iKV : m_crosspointValues)
106 //{
107 // dbgStr << int(iKV.first) << " - ";
108 // for (auto const& oKV : iKV.second)
109 // dbgStr << int(oKV.first) << ":" << oKV.second << ";";
110 // dbgStr << "\n";
111 //}
112 //DBG(juce::String(__FUNCTION__) + "\n" + dbgStr);
113
114 return m_crosspointValues;
115}
116
117void MemaClientControlComponentBase::addCrosspointStates(const std::map<std::uint16_t, std::map<std::uint16_t, bool>>& crosspointStates)
118{
119 auto crosspointStatesCpy = getCrosspointStates();
120
121 for (auto const& iKV : crosspointStates)
122 {
123 auto& input = iKV.first;
124 for (auto const& oKV : iKV.second)
125 {
126 auto& output = oKV.first;
127 auto& state = oKV.second;
128 crosspointStatesCpy[input][output] = state;
129 }
130 }
131 setCrosspointStates(crosspointStatesCpy);
132}
133
134void MemaClientControlComponentBase::addCrosspointValues(const std::map<std::uint16_t, std::map<std::uint16_t, float>>& crosspointValues)
135{
136 auto crosspointValuesCpy = getCrosspointValues();
137
138 for (auto const& iKV : crosspointValues)
139 {
140 auto& input = iKV.first;
141 for (auto const& oKV : iKV.second)
142 {
143 auto& output = oKV.first;
144 auto& value = oKV.second;
145 crosspointValuesCpy[input][output] = value;
146 }
147 }
148 setCrosspointValues(crosspointValuesCpy);
149}
150
152{
153 auto controlParametersStr = getIOCountParametersAsString() + "\n";
154 controlParametersStr += getInputMuteParametersAsString() + "\n";
155 controlParametersStr += getOutputMuteParametersAsString() + "\n";
156 controlParametersStr += getCrosspointParametersAsString();
157 return controlParametersStr;
158}
159
161{
162 auto controlParametersStr = juce::String("IO ");
163 controlParametersStr << getIOCount().first << "x" << getIOCount().second;
164 return controlParametersStr;
165}
166
168{
169 auto controlParametersStr = juce::String("InputMutes: ");
170 for (auto const& mutestate : getInputMuteStates())
171 controlParametersStr << int(mutestate.first) << ":" << (mutestate.second ? "on" : "off") << ";";
172 return controlParametersStr;
173}
174
176{
177 auto controlParametersStr = juce::String("OutputMutes: ");
178 for (auto const& mutestate : getOutputMuteStates())
179 controlParametersStr << int(mutestate.first) << ":" << (mutestate.second ? "on" : "off") << ";";
180 return controlParametersStr;
181}
182
184{
185 auto controlParametersStr = juce::String("Crosspoints:\n");
186 auto crosspointValues = getCrosspointValues();
187 for (auto const& crosspointstateFKV : getCrosspointStates())
188 {
189 auto& in = crosspointstateFKV.first;
190 for (auto const& crosspointstateSKV : crosspointstateFKV.second)
191 {
192 auto& out = crosspointstateSKV.first;
193 controlParametersStr << int(in) << "." << int(out) << ":" << (crosspointstateSKV.second ? "on" : "off") << "(" << crosspointValues[in][out] << ");";
194 }
195 controlParametersStr << "\n";
196 }
197 return controlParametersStr;
198}
199
200
201} // namespace Mema
const std::map< std::uint16_t, bool > & getInputMuteStates()
virtual void addCrosspointValues(const std::map< std::uint16_t, std::map< std::uint16_t, float > > &crosspointValues)
const std::map< std::uint16_t, bool > & getOutputMuteStates()
virtual void setControlsSize(const ControlsSize &ctrlsSize)
const std::map< std::uint16_t, std::map< std::uint16_t, bool > > & getCrosspointStates()
virtual void addCrosspointStates(const std::map< std::uint16_t, std::map< std::uint16_t, bool > > &crosspointStates)
virtual void setIOCount(const std::pair< int, int > &ioCount)
virtual void setCrosspointStates(const std::map< std::uint16_t, std::map< std::uint16_t, bool > > &crosspointStates)
virtual void setCrosspointValues(const std::map< std::uint16_t, std::map< std::uint16_t, float > > &crosspointValues)
virtual void setInputMuteStates(const std::map< std::uint16_t, bool > &inputMuteStates)
const std::map< std::uint16_t, std::map< std::uint16_t, float > > & getCrosspointValues()
virtual void setOutputMuteStates(const std::map< std::uint16_t, bool > &outputMuteStates)
ControlsSize
Size category for rendered control elements.
Definition Mema.cpp:27