Compare commits

..

12 Commits

Author SHA1 Message Date
7bbbdded3b add mark positions completed 2026-04-15 13:12:06 +03:00
70e1aa05b4 fix bad size 2026-04-13 17:48:11 +03:00
03fbd2bbb5 fix graph compression 2026-04-09 18:02:38 +03:00
377b7913bb fix compression 2026-04-07 18:52:29 +03:00
a279cdf3e3 add base change marker position 2026-04-07 15:02:06 +03:00
fc8467086a fix test sshd 2026-04-01 11:17:59 +03:00
5eb3f47194 fix test sshd 2026-03-31 17:21:55 +03:00
faf301b801 fix test sshd 2026-03-31 16:48:04 +03:00
df748a7072 fix sshd 2026-03-31 09:57:37 +03:00
29287712b5 fix player 2026-03-31 09:57:31 +03:00
29ff210adb fix play music then changing tabs 2026-03-28 21:56:42 +03:00
e45b65af23 fix show new opened tab 2026-03-28 21:24:44 +03:00
38 changed files with 452 additions and 407 deletions

View File

@@ -53,5 +53,3 @@ deps = [
subdir('src')
subdir('bin')
#############################################################

View File

@@ -21,9 +21,9 @@ headers = [
'monitor/utils/var.hpp',
'monitor/utils/func.hpp',
'monitor/utils/plugin.hpp',
'monitor/utils/plugins/raw_data.hpp',
'monitor/utils/plugins/magnitude.hpp',
'monitor/utils/plugins/fft.hpp',
'monitor/utils/plugins/raw_data/raw_data.hpp',
'monitor/utils/plugins/magnitude/magnitude.hpp',
'monitor/utils/plugins/fft/fft.hpp',
############ LIBS
'monitor/libs/audio/audio.hpp',
@@ -99,6 +99,9 @@ sources = [
############ UTILS
'monitor/libs/audio/audio.cpp',
'monitor/libs/gtkfd/gtkfd.cpp',
'monitor/utils/plugins/raw_data/raw_data.cpp',
'monitor/utils/plugins/magnitude/magnitude.cpp',
'monitor/utils/plugins/fft/fft.cpp',
]
lib = library(

View File

@@ -1,8 +1,10 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/libs/audio/audio.hpp"
#include "monitor/utils/var.hpp"
#include "monitor/utils/setup.hpp"
namespace monitor::components
{
@@ -18,9 +20,14 @@ namespace monitor::components
{
std::string m_id;
sf::Time m_current_time;
std::filesystem::path m_file;
utils::setup m_setup;
} m_current_audio;
std::map<std::string, music> m_audio_data;
std::size_t m_compression = 0;
std::vector<std::string> m_domains = { "time", "frequensy"};
@@ -31,11 +38,10 @@ namespace monitor::components
// делать
void drop();
void set_pos(double pos);
void set_step(std::size_t step);
private:
void init(std::string snapshot_id, std::filesystem::path file);
void init(std::string snapshot_id, utils::setup& setup);
void change(std::string snapshot_id);
void callback(sf::Time time, double pos);
void callback(sf::Time time);
};
}

View File

@@ -6,7 +6,7 @@ namespace monitor::components
void audio::on_attach()
{
CONNECT(this);
m_player.set_callback(std::bind(&audio::callback, this, std::placeholders::_1, std::placeholders::_2));
m_player.set_callback(std::bind(&audio::callback, this, std::placeholders::_1));
m_player.set_device();
}
@@ -31,11 +31,11 @@ namespace monitor::components
m_player.pause();
}
void audio::init(std::string snapshot_id, std::filesystem::path file)
void audio::init(std::string snapshot_id, utils::setup& setup)
{
m_player.stop();
m_current_audio = music{ .m_id = snapshot_id, .m_current_time = sf::Time(), .m_file = file };
m_audio_data[snapshot_id] = m_current_audio;
m_audio_data[snapshot_id] = music{ .m_id = snapshot_id, .m_current_time = sf::Time(), .m_setup = setup };
m_status = utils::var::STATUS::ACTIVE;
}
void audio::change(std::string snapshot_id)
@@ -43,20 +43,27 @@ namespace monitor::components
m_audio_data[m_current_audio.m_id].m_current_time = m_current_audio.m_current_time;
m_player.stop();
m_current_audio = m_audio_data[snapshot_id];
m_player.set_file(m_current_audio.m_file);
m_player.set_file(m_current_audio.m_setup.m_file);
m_player.set_audio_pos(m_current_audio.m_current_time);
callback(m_current_audio.m_current_time);
}
void audio::callback(sf::Time time, double pos)
void audio::callback(sf::Time time)
{
m_current_audio.m_current_time = time;
// HERE
// начинаем тут, делаем установку мсаркера проигрывания
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, pos };
double seconds = time.asSeconds();
double current_sample_index = seconds * m_current_audio.m_setup.m_sample_rate / m_compression;
// send to:: components/markers
VE::event e { utils::event_type::SET_MARKER_AUDIO_POSITION, current_sample_index };
EMIT(e);
}
// делать
// HERE
// делать нужно, но надо разобраться зачем?
void audio::drop()
{
m_player.stop();
@@ -68,10 +75,4 @@ namespace monitor::components
{
m_player.set_audio_pos(pos);
}
// step - шаг отправки сигнала на смещение маркера. он же кол-во block_size-ов на все произведение
void audio::set_step(std::size_t step)
{
m_player.set_step(step);
}
}

View File

@@ -1,4 +1,3 @@
#include <harmonica.hpp>
#include "monitor/gui/components/audio/audio.hpp"
#include "monitor/utils/event_type.hpp"
@@ -27,21 +26,14 @@ namespace monitor::components
switch (type)
{
case utils::event_type::SET_AUDIO_STATUS:
case utils::event_type::INIT_AUDIO:
{
m_status = std::any_cast<utils::var::STATUS>(e.m_data);
auto [snapshot_id, setup] = std::any_cast<std::pair<std::string, utils::setup>>(e.m_data);
init(snapshot_id, setup);
break;
}
case utils::event_type::SET_AUDIO_FILE:
{
auto [snapshot_id, file] = std::any_cast<std::pair<std::string, std::filesystem::path>>(e.m_data);
init(snapshot_id, file);
change(snapshot_id);
break;
}
case utils::event_type::CHANGE_AUDIO_FILE:
case utils::event_type::CHANGE_AUDIO:
{
auto snapshot_id = std::any_cast<std::string>(e.m_data);
change(snapshot_id);
@@ -54,6 +46,12 @@ namespace monitor::components
break;
}
case utils::event_type::SET_COMPRESSION:
{
m_compression = std::any_cast<std::size_t>(e.m_data);
break;
}
case utils::event_type::SET_AUDIO_POSITION:
{
auto d = std::any_cast<double>(e.m_data);

View File

@@ -1,6 +1,7 @@
#pragma once
#include <VE.hpp>
#include "monitor/utils/setup.hpp"
#include "monitor/gui/components/graph/graph.hpp"
#include "monitor/gui/components/fft_scaled/fft_scaled.hpp"
@@ -24,11 +25,15 @@ namespace monitor::components
fft_scaled m_fft_scaled;
private:
hr::setup m_setup;
utils::setup m_setup;
std::vector<std::shared_ptr<utils::plugin>> m_base_plugins;
public:
void init(std::string snapshot_id, hr::setup setup);
void init(std::string snapshot_id, utils::setup setup);
private:
void calculate_plugin(std::shared_ptr<utils::plugin> plugin);
void change_tab(std::size_t index);
};
}

View File

@@ -1,6 +1,7 @@
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
#include "monitor/utils/plugins/raw_data.hpp"
#include "monitor/utils/plugins/magnitude.hpp"
#include "monitor/utils/plugins/raw_data/raw_data.hpp"
#include "monitor/utils/plugins/magnitude/magnitude.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
@@ -11,8 +12,8 @@ namespace monitor::components
m_graph.on_attach();
m_fft_scaled.on_attach();
m_base_plugins.push_back(std::make_shared<utils::plugin>(utils::plugins::raw_data{}));
m_base_plugins.push_back(std::make_shared<utils::plugin>(utils::plugins::magnitude{}));
m_base_plugins.push_back(std::make_shared<utils::plugins::raw_data>());
m_base_plugins.push_back(std::make_shared<utils::plugins::magnitude>());
m_size.x = VE::application::get()->get_glfw()->width() - VE::application::get()->get_glfw()->width() / 4.f;
m_size.y = VE::application::get()->get_glfw()->height() / 2.f;
@@ -31,13 +32,60 @@ namespace monitor::components
m_fft_scaled.update();
}
void base_plugins::init(std::string snapshot_id, hr::setup setup)
void base_plugins::init(std::string snapshot_id, utils::setup setup)
{
m_snapshot_id = snapshot_id;
m_setup = setup;
m_graph.init(m_snapshot_id, m_setup);
m_graph.set_plugin(m_base_plugins[0]);
m_graph.init(m_snapshot_id, m_setup);
// m_fft_scaled.init(m_snapshot_id, m_setup);
change_tab(0);
// send to: components/audio
VE::event e { utils::event_type::INIT_AUDIO, std::pair<std::string, utils::setup>(m_snapshot_id, m_setup) };
EMIT(e);
}
void base_plugins::change_tab(std::size_t index)
{
m_current_open_index = index;
calculate_plugin(m_base_plugins[index]);
m_graph.set_plugin(m_base_plugins[index]);
// send to: components/audio
VE::event e { utils::event_type::SET_COMPRESSION, m_base_plugins[index]->m_compression_step };
EMIT(e);
}
void base_plugins::calculate_plugin(std::shared_ptr<utils::plugin> plugin)
{
if (!plugin->empty()) return;
switch (plugin->m_type)
{
case utils::plugin::TYPE::RAW_DATA:
{
m_setup.m_domain = hr::DOMAIN_PLUGIN::TIME;
plugin->m_result = hr::run<hr::plugins::raw_data>(m_setup);
break;
}
case utils::plugin::TYPE::MAGNITUDE:
{
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
plugin->m_result = hr::run<hr::plugins::magnitude>(m_setup);
break;
}
}
if (!plugin->empty())
{
plugin->init(m_setup);
plugin->fill();
}
else
{
hack::error()("NOT SET DATA!");
}
}
}

View File

@@ -11,11 +11,16 @@ namespace monitor::components
switch (type)
{
// case utils::event_type::CREATE_SNAPSHOT_COMPLETED:
// {
// clear();
// break;
// }
case utils::event_type::PREPARE_BASE_PLUGIN_COMPRESSION:
{
auto snapshot_id = std::any_cast<std::string>(e.m_data);
if (m_snapshot_id != snapshot_id) return;
// send to: components/audio
VE::event e { utils::event_type::SET_COMPRESSION, m_base_plugins[m_current_open_index]->m_compression_step };
EMIT(e);
break;
}
}
}
}

View File

@@ -22,11 +22,7 @@ namespace monitor::components
ImGui::EndTabItem();
}
if (ImGui::IsItemClicked())
{
m_current_open_index = i;
m_graph.set_plugin(m_base_plugins[i]);
}
if (ImGui::IsItemClicked()) change_tab(i);
}
ImGui::EndTabBar();
}

View File

@@ -32,10 +32,12 @@ namespace monitor::components
void creator::clear()
{
m_status = utils::var::STATUS::COMPLETED;
auto future = std::async(std::launch::async, [this]() {
std::this_thread::sleep_for(std::chrono::seconds(1));
auto f = [this]() {
std::this_thread::sleep_for(std::chrono::seconds(3));
m_file_path.clear();
m_status = utils::var::STATUS::EMPTY;
});
};
std::thread th(f);
th.detach();
}
}

View File

@@ -8,7 +8,7 @@ namespace monitor::components
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
std::size_t step = 256;
// block_size
// BLOCK SIZE
ImGui::Text("block size:");
ImGui::SameLine(0.0f, spacing);
@@ -37,11 +37,11 @@ namespace monitor::components
ImGui::PopID();
VE_POP_FONT();
ImGui::PopItemFlag();
// end
// end BLOCK SIZE
ImGui::SameLine(0.f, 3.f * spacing);
// step size
// STEP SIZE
ImGui::Text("step size:");
ImGui::SameLine(0.0f, spacing);
@@ -70,6 +70,6 @@ namespace monitor::components
ImGui::PopID();
VE_POP_FONT();
ImGui::PopItemFlag();
// end
// end STEP SIZE
}
}

View File

@@ -5,6 +5,7 @@
#include "monitor/gui/components/spinner/spinner.hpp"
#include "monitor/gui/components/file_dialog/file_dialog.hpp"
#include "monitor/utils/var.hpp"
#include "monitor/utils/setup.hpp"
namespace monitor::components
{
@@ -18,13 +19,15 @@ namespace monitor::components
components::spinner m_spinner;
private:
hr::setup m_setup;
utils::setup m_setup;
file_dialog m_fd;
std::filesystem::path m_file_path;
private:
void render_setup();
void render_spinner(ImVec2 pos = { 10.f, 8.f });
private:
void create();
void clear();
};

View File

@@ -2,7 +2,7 @@
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/utils/plugins/fft.hpp"
#include "monitor/utils/plugins/fft/fft.hpp"
namespace monitor::components
{

View File

@@ -30,33 +30,10 @@ namespace monitor::components
{
m_plugin = std::move(plugin);
if (!m_plugin) hack::error()("The object is not installed");
}
if (m_plugin->empty())
{
switch (m_plugin->m_type)
{
case utils::plugin::TYPE::RAW_DATA:
{
m_setup.m_domain = hr::DOMAIN_PLUGIN::TIME;
m_plugin->m_result = hr::run<hr::plugins::raw_data>(m_setup);
break;
}
case utils::plugin::TYPE::MAGNITUDE:
{
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
m_plugin->m_result = hr::run<hr::plugins::magnitude>(m_setup);
break;
}
}
if (!m_plugin->empty())
{
m_plugin->init();
m_plugin->fill();
}
else
{
hack::error()("NOT SET RAW DATA!");
}
}
std::size_t graph::get_plugin_size() noexcept
{
return m_plugin->m_size;
}
}

View File

@@ -21,6 +21,7 @@ namespace monitor::components
public:
void init(std::string snapshot_id, hr::setup setup);
void set_plugin(std::shared_ptr<utils::plugin> plugin) noexcept;
std::size_t get_plugin_size() noexcept;
private:
std::shared_ptr<utils::plugin> m_plugin;

View File

@@ -1,5 +1,6 @@
#include "monitor/gui/components/markers/markers.hpp"
#include "monitor/utils/event_type.hpp"
#include <SFML/Audio.hpp>
namespace monitor::components
{
@@ -33,13 +34,6 @@ namespace monitor::components
auto type = std::any_cast<utils::event_type>(e.m_type);
switch (type)
{
case utils::event_type::INCREMENT_MARKER_AUDIO_POSITION:
{
auto pos = std::any_cast<double>(e.m_data);
m_marker_audio_position += pos;
break;
}
case utils::event_type::SET_MARKER_AUDIO_POSITION:
{
auto pos = std::any_cast<double>(e.m_data);

View File

@@ -5,9 +5,9 @@ namespace monitor::components
{
void markers::render()
{
// -1 это индекс т.к. там внизу тоже они индексируются
// 0 это индекс т.к. там внизу тоже они индексируются
// ImPlotDragToolFlags_NoInputs - не дает передвинуть маркер
ImPlot::DragLineX(-1, &m_marker_audio_position, m_marker_audio_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
ImPlot::DragLineX(0, &m_marker_audio_position, m_marker_audio_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
// кликаем для установки маркера аудио (зеленый)
if (ImGui::IsMouseClicked(ImGuiMouseButton_Middle))
@@ -21,7 +21,7 @@ namespace monitor::components
if (m_shift_press && ImPlot::IsPlotHovered())
{
m_marker_mouse_position = ImPlot::GetPlotMousePos().x;
ImPlot::DragLineX(1000, &m_marker_mouse_position, m_marker_mouse_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
ImPlot::DragLineX(1, &m_marker_mouse_position, m_marker_mouse_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace monitor::components
private:
ImVec4 m_marker_audio_color;
ImVec4 m_marker_mouse_color;
double m_marker_audio_position = 100.0;
double m_marker_audio_position = 0.0;
double m_marker_mouse_position = 100.0;
bool m_shift_press = false;
};

View File

@@ -1,6 +1,5 @@
#include "monitor/gui/components/snapshot/snapshot.hpp"
#include "monitor/utils/var.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
@@ -27,16 +26,10 @@ namespace monitor::components
m_status = s;
}
void snapshot::init(hr::setup setup)
void snapshot::init(utils::setup setup)
{
m_snapshot_id = hack::security::generate_uuid();
m_setup = setup;
m_base_plugins.init(m_snapshot_id, m_setup);
VE::event e1 { utils::event_type::SET_AUDIO_STATUS, utils::var::STATUS::ACTIVE };
EMIT(e1);
VE::event e2 { utils::event_type::SET_AUDIO_FILE, std::pair<std::string, std::filesystem::path>(m_snapshot_id, setup.m_file) };
EMIT(e2);
}
}

View File

@@ -11,94 +11,5 @@ namespace monitor::components
ImGui::PushID("scale");
m_base_controls.render();
ImGui::PopID();
// m_audio.render();
//
// ImGui::SameLine();
//
// // HERE
// // выбор домена для плагина
// auto ctx = ImGui::GetCurrentContext();
// ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
// ImGui::SetNextItemWidth(120.f);
// static std::size_t domain_id = 0;
// if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
// {
// for (std::size_t i = 0; i < m_domains.size(); ++i)
// {
// const bool is_selected = (domain_id == i);
// if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
// domain_id = i;
// if (is_selected) ImGui::SetItemDefaultFocus();
// }
// ImGui::EndCombo();
// }
//
// ImGui::SameLine();
//
// ImGui::SetNextItemWidth(400.f);
// if (ImGui::BeginCombo(VE_NO_NAME("select_plugin"), m_plugin.m_id < 0 ? "---" : m_plugins[m_plugin.m_id].m_name.c_str()))
// {
// for (std::size_t i = 0; i < m_plugins.size(); ++i)
// {
// const bool is_selected = (m_plugin.m_id == static_cast<int>(i));
// if (ImGui::Selectable(m_plugins[i].m_name.c_str(), is_selected))
// m_plugin = m_plugins[i];
// if (is_selected) ImGui::SetItemDefaultFocus();
// }
// ImGui::EndCombo();
// }
//
// ImGui::SameLine();
//
// if (ImGui::Button("add plugin", ImVec2{ 94.f, 27.f })) add_plugin();
//
// if (ImPlot::BeginSubplots(VE_NO_NAME("graph" + m_snapshot_id), m_rows, m_cols, ImVec2(-1, -1), ImPlotSubplotFlags_LinkRows | ImPlotSubplotFlags_LinkCols))
// {
// for (const auto& graph : m_graphs)
// {
// if (ImPlot::BeginPlot(VE_NAME(graph.m_name), ImVec2(-1, 0), ImPlotFlags_NoMenus))
// {
// // по оси X
// ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_Opposite | // смена полюсов у надписей оси x. они вверху
// ImPlotAxisFlags_NoSideSwitch | // нельзя перетаскивать оси по сторонам
// (is_first_render ? ImPlotAxisFlags_AutoFit : ImPlotAxisFlags_None) | // авто подстройка размера по горизонтале
// ImPlotAxisFlags_NoHighlight, // не разобрался что это там подсвечивается, что-то с фоном оси
// // по оси Y
// ImPlotAxisFlags_AutoFit | // авто подстройка размера по вертикале
// ImPlotAxisFlags_NoSideSwitch |
// ImPlotAxisFlags_NoHighlight |
// ImPlotAxisFlags_NoTickLabels // текстовые надписи отображаться не будут
// );
//
// ImPlot::SetupAxisLimits(ImAxis_X1, 0.f, graph.m_render_data[0].size());
// ImPlot::SetupAxisLimits(ImAxis_Y1, 0.f, graph.m_max_element);
// ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 0, INFINITY);
// ImPlot::SetupLegend(ImPlotLocation_NorthEast);
//
//
// std::size_t index = 0;
// for (auto& line : graph.m_render_data)
// {
// if (graph.m_type == utils::var::PLUGIN_TYPE::SEGMENTER)
// ImPlot::PlotStems(VE_NAME(std::to_string(index)), graph.m_ox.data(), line.data(), line.size());
// else
// ImPlot::PlotLine(VE_NAME(std::to_string(index)), graph.m_ox.data(), line.data(), line.size());
// ++index;
// }
//
// if (graph.m_type != utils::var::PLUGIN_TYPE::MAGNITUDE) m_markers.set_tag_show(false);
// else m_markers.set_tag_show(true);
//
// m_markers.render();
//
// ImPlot::EndPlot();
// }
// }
// ImPlot::EndSubplots();
// }
//
// is_first_render = false;
}
}

View File

@@ -1,8 +1,8 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/utils/var.hpp"
#include "monitor/utils/setup.hpp"
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
#include "monitor/gui/components/base_controls/base_controls.hpp"
@@ -20,7 +20,7 @@ namespace monitor::components
public:
std::string m_snapshot_id;
utils::var::STATUS m_status;
hr::setup m_setup;
utils::setup m_setup;
private:
ImVec2 m_size = { 0.f, 0.f };
@@ -49,6 +49,6 @@ namespace monitor::components
public:
void set_status(utils::var::STATUS s);
void init(hr::setup setup);
void init(utils::setup setup);
};
}

View File

@@ -6,6 +6,9 @@ namespace monitor::components
void tabs::on_attach()
{
CONNECT(this);
hack::log().on_full_path();
hack::log().set_devider(" = ");
}
void tabs::on_detach()
@@ -22,15 +25,17 @@ namespace monitor::components
for (auto & s : m_snapshots) s->update();
}
void tabs::create_snapshot(hr::setup setup)
void tabs::create_snapshot(utils::setup setup)
{
auto s = std::make_shared<snapshot>();
s->on_attach();
s->init(setup);
m_snapshots.push_back(s);
VE::event e0 { utils::event_type::CREATE_SNAPSHOT_COMPLETED, nullptr };
EMIT(e0);
VE::event e { utils::event_type::CREATE_SNAPSHOT_COMPLETED, nullptr };
EMIT(e);
change_tab(m_snapshots.size() - 1);
}
void tabs::change_tab(std::size_t i)
@@ -39,7 +44,12 @@ namespace monitor::components
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
m_current_open_index = i;
VE::event e { utils::event_type::CHANGE_AUDIO_FILE, m_snapshots[i]->m_snapshot_id };
EMIT(e);
// send to: components/base_plugins
VE::event e0 { utils::event_type::PREPARE_BASE_PLUGIN_COMPRESSION, m_snapshots[i]->m_snapshot_id };
EMIT(e0);
// send to: components/audio
VE::event e1 { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id };
EMIT(e1);
};
}

View File

@@ -13,7 +13,7 @@ namespace monitor::components
{
case utils::event_type::CREATE_SNAPSHOT:
{
auto data = std::any_cast<hr::setup>(e.m_data);
auto data = std::any_cast<utils::setup>(e.m_data);
create_snapshot(data);
break;
}

View File

@@ -3,6 +3,7 @@
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/gui/components/snapshot/snapshot.hpp"
#include "monitor/utils/setup.hpp"
namespace monitor::components
{
@@ -18,7 +19,7 @@ namespace monitor::components
std::size_t m_current_open_index = 0;
private:
void create_snapshot(hr::setup setup);
void create_snapshot(utils::setup setup);
void change_tab(std::size_t i);
};
}

View File

@@ -15,7 +15,7 @@ namespace monitor::libs
// сделать выбор устройства из интерфейса
// поставь, то которое есть в списке устройств
for (auto& d : devices) std::cout << d << std::endl;
std::string target_device = devices[2];
std::string target_device = devices[1];
if (sf::PlaybackDevice::setDevice(target_device))
hack::log()("Устройство успешно установлено: ", target_device);
else
@@ -25,12 +25,9 @@ namespace monitor::libs
void audio::set_file(std::filesystem::path p)
{
if (!m_music.openFromFile(p)) hack::error()("dont open file:", p.string());
std::vector<std::string> devices = sf::PlaybackDevice::getAvailableDevices();
std::string targetDevice = devices[1];
}
void audio::set_callback(std::function<void(sf::Time, float)> c)
void audio::set_callback(std::function<void(sf::Time)> c)
{
m_callback = c;
}
@@ -40,11 +37,6 @@ namespace monitor::libs
m_music.setPlayingOffset(t);
}
void audio::set_step(std::size_t step)
{
// m_step = sf::microseconds(m_music.getDuration().asMicroseconds() / step);
}
void audio::set_audio_pos(double s)
{
// m_ct = sf::microseconds(s * m_step.asMicroseconds());
@@ -67,8 +59,8 @@ namespace monitor::libs
{
while (is_playing())
{
m_callback(m_music.getPlayingOffset(), 1.0);
sf::sleep(m_step);
m_callback(m_music.getPlayingOffset());
sf::sleep(sf::milliseconds(20));
}
}

View File

@@ -20,8 +20,7 @@ namespace monitor::libs
void pause();
void toggle_play();
bool is_playing();
void set_callback(std::function<void(sf::Time, float)> c);
void set_step(std::size_t step);
void set_callback(std::function<void(sf::Time)> c);
void set_audio_pos(double s);
void set_audio_pos(sf::Time t);
@@ -33,7 +32,7 @@ namespace monitor::libs
sf::Music m_music;
sf::Time m_ct = sf::Time::Zero;
sf::Time m_step = sf::Time::Zero;
std::function<void(sf::Time, float)> m_callback;
std::function<void(sf::Time)> m_callback;
};
}

View File

@@ -8,9 +8,11 @@ namespace monitor::utils
CREATE_SNAPSHOT_COMPLETED,
STATUS_PROCESS,
STATUS_COMPLETED,
SET_AUDIO_STATUS,
SET_AUDIO_FILE,
CHANGE_AUDIO_FILE,
INIT_AUDIO,
CHANGE_AUDIO,
SET_COMPRESSION,
SET_MARKER_AUDIO_POSITION,
PREPARE_BASE_PLUGIN_COMPRESSION,
/// делать
@@ -18,8 +20,6 @@ namespace monitor::utils
AUDIO_PAUSE,
AUDIO_STOP,
INCREMENT_MARKER_AUDIO_POSITION,
SET_MARKER_AUDIO_POSITION,
SET_MARKER_MOUSE_POSITION
};
}

View File

@@ -31,8 +31,8 @@ namespace monitor::utils
// градуировка осьи X
hr::fvec_t m_ox;
// размер данных для отрисовки. уситанавливает размер графика
// штука плавающая в зависимости от масштаба
// размер данных для отрисовки. устанавливает размер графика
// и он меняется в зависимости от компересии
std::size_t m_size = utils::var::MAX_RENDER_SIZE;
// кол-во линий графика
@@ -44,86 +44,15 @@ namespace monitor::utils
std::vector<hr::fvec_t> m_line_data;
// говорит нужно ли делать сжатие графика ли нет
bool m_is_scale = false;
bool m_compression = false;
std::size_t m_step = 0;
// это кол-во точек, которые нужно отрисовать с учетом текущего масштаба но в прошлом шаге
std::size_t m_past_k2 = 0;
// шаг сжатия
std::size_t m_compression_step = 0;
public:
virtual bool empty() { return m_result.empty(); }
virtual void init()
{
try
{
auto raw_data_size = m_result.m_size;
if (raw_data_size == 0) throw std::invalid_argument("Error set data in plugin: empty data");
m_is_scale = raw_data_size > m_size;
m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count);
for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
m_ox.reserve(m_size);
fill_ox();
}
catch(std::exception& e)
{
hack::error()(e.what());
}
}
virtual void fill_ox(std::size_t start_pos = 0)
{
m_ox.clear();
for (std::size_t i = start_pos; i < m_size + start_pos; ++i) m_ox.push_back(i);
}
// этот метод запускается один раз при первом рендеринге
// для заполнения начальными данными
virtual void fill()
{
if (m_is_scale)
{
m_step = m_result.m_size / m_size + 1;
std::size_t line_count = 0;
for (auto& gd : m_line_data)
{
std::size_t bin_index = 0;
for (auto& g : gd)
{
float tmp_e = 0.f;
for (std::size_t j = bin_index - m_step; j < bin_index; ++j)
{
auto e = m_result.m_data[line_count][j].m_value;
tmp_e = hack::math::max_abs(e, tmp_e);
}
g = tmp_e;
bin_index += m_step;
if (bin_index > m_result.m_size) bin_index = m_result.m_size;
}
++line_count;
}
}
else
{
// заполняется, когда данных пришло меньше чем нужно для полного рендеринга
std::size_t line_count = 0;
for (auto el : m_result.m_data)
{
std::size_t bin_index = 0;
for (auto e : el)
{
m_line_data[line_count][bin_index] = e.m_value;
++bin_index;
}
++line_count;
}
}
}
virtual bool empty() = 0;
virtual void init(hr::setup setup) = 0;
virtual void fill() = 0;
virtual void set_ox(std::size_t start_pos = 0) = 0;
};
}

View File

@@ -1,63 +0,0 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct fft : public plugin
{
fft()
{
m_type = plugin::TYPE::FFT;
m_display_name = "FFT";
}
virtual void init()
{
try
{
// тут просто берем из первой линии, первые данные, т.к это fft см. реализацию самого плагина в harmonica
auto raw_size = m_result.m_data[0][0].m_values.size();
if (raw_size == 0) throw std::invalid_argument("Error set data in plugin: empty data");
// m_is_scale = raw_size > var::MAX_RENDER_SIZE;
// m_size = std::min(raw_size, var::MAX_RENDER_SIZE);
m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count);
m_ox.reserve(m_result.m_grad.size());
for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
fill_ox();
}
catch(std::exception& e)
{
hack::error()(e.what());
}
}
virtual void fill_ox(std::size_t start_pos = 0)
{
for (auto x : m_result.m_grad) m_ox.push_back(x);
}
// этот метод запускается один раз при первом рендеринге
// для заполнения начальными данными
virtual void fill()
{
if (m_is_scale) hack::error()("ДАнных больше чем можем отрисовать на экране, см. что-то с масштабированием...");
std::size_t line_count = 0;
for (auto el : m_result.m_data)
{
std::size_t index = 0;
for (auto e : el)
{
m_line_data[line_count][index] = e.m_value;
++index;
}
++line_count;
}
}
};
}

View File

@@ -0,0 +1,61 @@
#include "fft.hpp"
namespace monitor::utils::plugins
{
fft::fft()
{
m_type = plugin::TYPE::FFT;
m_display_name = "FFT";
}
void fft::init(hr::setup setup)
{
try
{
// тут просто берем из первой линии, первые данные, т.к это fft см. реализацию самого плагина в harmonica
auto raw_size = m_result.m_data[0][0].m_values.size();
if (raw_size == 0) throw std::invalid_argument("Error set data in plugin: empty data");
// m_is_scale = raw_size > var::MAX_RENDER_SIZE;
// m_size = std::min(raw_size, var::MAX_RENDER_SIZE);
m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count);
m_ox.reserve(m_result.m_grad.size());
for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
set_ox();
}
catch(std::exception& e)
{
hack::error()(e.what());
}
}
void fft::set_ox(std::size_t start_pos)
{
for (auto x : m_result.m_grad) m_ox.push_back(x);
}
void fft::fill()
{
if (m_compression) hack::error()("Данных больше чем можем отрисовать на экране, см. что-то с масштабированием...");
std::size_t line_count = 0;
for (auto el : m_result.m_data)
{
std::size_t index = 0;
for (auto e : el)
{
m_line_data[line_count][index] = e.m_value;
++index;
}
++line_count;
}
}
bool fft::empty()
{
return m_result.empty();
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct fft : public plugin
{
fft();
~fft() = default;
void init(hr::setup setup) override;
void set_ox(std::size_t start_pos = 0) override;
void fill() override;
bool empty() override;
};
}

View File

@@ -1,17 +0,0 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct magnitude : public plugin
{
magnitude()
{
m_type = plugin::TYPE::MAGNITUDE;
m_display_name = "Magnitude";
}
};
}

View File

@@ -0,0 +1,56 @@
#include "magnitude.hpp"
namespace monitor::utils::plugins
{
magnitude::magnitude()
{
m_type = plugin::TYPE::MAGNITUDE;
m_display_name = "Magnitude";
}
void magnitude::init(hr::setup setup)
{
try
{
m_size = m_result.m_size;
m_compression_step = setup.m_step_size;
m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count);
for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
set_ox();
}
catch(std::exception& e)
{
hack::error()(e.what());
}
}
void magnitude::fill()
{
std::size_t line_count = 0;
for (auto el : m_result.m_data)
{
std::size_t bin_index = 0;
for (auto e : el)
{
m_line_data[line_count][bin_index] = e.m_value;
++bin_index;
}
++line_count;
}
}
void magnitude::set_ox(std::size_t start_pos)
{
m_ox.reserve(m_size);
for (std::size_t i = start_pos; i < m_size + start_pos; ++i) m_ox.push_back(i);
}
bool magnitude::empty()
{
return m_result.empty();
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct magnitude : public plugin
{
magnitude();
~magnitude() = default;
void init(hr::setup setup) override;
void fill() override;
void set_ox(std::size_t start_pos = 0) override;
bool empty() override;
};
}

View File

@@ -1,17 +0,0 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct raw_data : public plugin
{
raw_data()
{
m_type = plugin::TYPE::RAW_DATA;
m_display_name = "Raw Data";
}
};
}

View File

@@ -0,0 +1,82 @@
#include "raw_data.hpp"
namespace monitor::utils::plugins
{
raw_data::raw_data()
{
m_type = plugin::TYPE::RAW_DATA;
m_display_name = "Raw Data";
}
void raw_data::init(hr::setup setup)
{
try
{
m_compression = m_result.m_size > m_size;
if (!m_compression) m_size = m_result.m_size;
m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count);
for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
set_ox();
}
catch(std::exception& e)
{
hack::error()(e.what());
}
}
void raw_data::fill()
{
if (m_compression)
{
m_compression_step = m_result.m_size / m_size + 1;
std::size_t line_count = 0;
for (auto& gd : m_line_data)
{
std::size_t bin_index = 0;
for (auto& g : gd)
{
float tmp_e = 0.f;
for (std::size_t j = bin_index - m_compression_step; j < bin_index; ++j)
{
auto e = m_result.m_data[line_count][j].m_value;
tmp_e = hack::math::max_abs(e, tmp_e);
}
g = tmp_e;
bin_index += m_compression_step;
if (bin_index > m_result.m_size) bin_index = m_result.m_size;
}
m_size = bin_index / m_compression_step;
++line_count;
}
}
else
{
std::size_t line_count = 0;
for (auto el : m_result.m_data)
{
std::size_t bin_index = 0;
for (auto e : el)
{
m_line_data[line_count][bin_index] = e.m_value;
++bin_index;
}
++line_count;
}
}
}
void raw_data::set_ox(std::size_t start_pos)
{
m_ox.reserve(m_size);
for (std::size_t i = start_pos; i < m_size + start_pos; ++i) m_ox.push_back(i);
}
bool raw_data::empty()
{
return m_result.empty();
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "monitor/utils/plugin.hpp"
namespace monitor::utils::plugins
{
struct raw_data : public plugin
{
raw_data();
~raw_data() = default;
void init(hr::setup setup) override;
void fill() override;
void set_ox(std::size_t start_pos = 0) override;
bool empty() override;
};
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <harmonica.hpp>
namespace monitor::utils
{
struct setup : public hr::setup
{
// // это меняющеесе значение в зависимости от плагина, а не
// // как может показаться от аудио файла
// std::size_t m_graph_compression = 0;
};
}