-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
93 lines (71 loc) · 2.53 KB
/
Copy pathmain.cpp
File metadata and controls
93 lines (71 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright (C) 2024-2026, Sylwester Kominek
* This file is part of SpectrumAnalyzer program licensed under GPLv2 or later,
* see file LICENSE in this source tree.
*/
#include "core/AudioSpectrumAnalyzer.hpp"
#include "core/StereoRmsMeter.hpp"
#include "core/ConfigReader.hpp"
#include <iostream>
void printLicense()
{
const std::string license = R"(Copyright (C) 2024-2026, Sylwester Kominek
Source code: https://github.com/sylwekkominek/SpectrumAnalyzer
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
PRESS 0–9 TO CHANGE THE COLOR THEME
)";
std::cout<<license<<std::endl;
}
void updateStates(ThemeConfig &theme, ApplicationState &state, const AppEvent &event)
{
std::visit([&](auto&& v)
{
using T = std::decay_t<decltype(v)>;
if constexpr (std::is_same_v<T, ThemeConfig>)
{
theme = v;
}
else if constexpr (std::is_same_v<T, ApplicationState>)
{
state = v;
}
}, event);
}
std::unique_ptr<SpectrumAnalyzerBase> createAnalyzer(Mode mode, const Configuration &config)
{
switch(mode)
{
case Mode::StereoRmsMeter:
return std::make_unique<StereoRmsMeter>(config);
default:
return std::make_unique<AudioSpectrumAnalyzer>(config);
}
}
int main()
{
printLicense();
const Mode mode = Mode::Analyzer;
ThemeConfig currentTheme = ThemeConfig::Theme1;
ApplicationState currentAppState = ApplicationState::Running;
while (currentAppState != ApplicationState::Shutdown)
{
ConfigReader configReader(currentTheme, mode);
const Configuration &config = configReader.getConfig();
std::cout << config << std::endl;
std::unique_ptr<SpectrumAnalyzerBase> spectrumAnalyzer = createAnalyzer(mode, config);
spectrumAnalyzer->init();
spectrumAnalyzer->run();
AppEvent event = spectrumAnalyzer->getEvent();
updateStates(currentTheme, currentAppState, event);
}
return 0;
}