Mema
Memory Matrix — multi-channel audio matrix monitor and router
Loading...
Searching...
No Matches
ProcessorLevelData.h
Go to the documentation of this file.
1/* Copyright (c) 2024-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
19#pragma once
20
22
23namespace Mema
24{
25
28{
29public:
31 struct LevelVal
32 {
34 {
35 peak = 0.0f;
36 rms = 0.0f;
37 hold = 0.0f;
38 peakdB = 0.0f;
39 rmsdB = 0.0f;
40 holddB = 0.0f;
41 minusInfdb = -10000.0f;
42 }
43 LevelVal(float p, float r, float h, float infdb = -100.0f)
44 {
45 peak = p;
46 rms = r;
47 hold = h;
48 peakdB = juce::Decibels::gainToDecibels(peak, infdb);
49 rmsdB = juce::Decibels::gainToDecibels(rms, infdb);
50 holddB = juce::Decibels::gainToDecibels(hold, infdb);
51 minusInfdb = infdb;
52 }
53
55 {
56 return (-1 * minusInfdb + rmsdB) / (-1 * minusInfdb);
57 }
59 {
60 return (-1 * minusInfdb + peakdB) / (-1 * minusInfdb);
61 }
63 {
64 return (-1 * minusInfdb + holddB) / (-1 * minusInfdb);
65 }
66
67 float peak;
68 float rms;
69 float hold;
70 float peakdB;
71 float rmsdB;
72 float holddB;
73 float minusInfdb;
74 };
75
76public:
79
80 void SetLevel(unsigned long channel, LevelVal level);
81 LevelVal GetLevel(unsigned long channel);
82
83 void SetChannelCount(unsigned long count) override;
84 unsigned long GetChannelCount() override;
85
86private:
87 std::map<unsigned long, LevelVal> m_levelMap;
88};
89
90}
Base class for all data objects exchanged between the audio processor and its analyzers/visualisers.
void SetLevel(unsigned long channel, LevelVal level)
void SetChannelCount(unsigned long count) override
Sets the number of audio channels this data object covers.
LevelVal GetLevel(unsigned long channel)
unsigned long GetChannelCount() override
Returns the number of audio channels this data object covers.
Definition Mema.cpp:27
Per-channel level values in both linear and dB domains.
float minusInfdb
Value used as -infinity in dB calculations.
LevelVal(float p, float r, float h, float infdb=-100.0f)