add mark positions completed

This commit is contained in:
2026-04-15 13:12:06 +03:00
parent 70e1aa05b4
commit 7bbbdded3b
18 changed files with 65 additions and 72 deletions

View File

@@ -23,6 +23,7 @@ namespace monitor::components
utils::setup m_setup; utils::setup m_setup;
} m_current_audio; } m_current_audio;
std::map<std::string, music> m_audio_data; std::map<std::string, music> m_audio_data;
std::size_t m_compression = 0;

View File

@@ -52,7 +52,7 @@ namespace monitor::components
{ {
m_current_audio.m_current_time = time; m_current_audio.m_current_time = time;
double seconds = time.asSeconds(); double seconds = time.asSeconds();
double current_sample_index = seconds * m_current_audio.m_setup.m_sample_rate / m_current_audio.m_setup.m_graph_compression; double current_sample_index = seconds * m_current_audio.m_setup.m_sample_rate / m_compression;
// send to:: components/markers // send to:: components/markers
VE::event e { utils::event_type::SET_MARKER_AUDIO_POSITION, current_sample_index }; VE::event e { utils::event_type::SET_MARKER_AUDIO_POSITION, current_sample_index };

View File

@@ -46,6 +46,12 @@ namespace monitor::components
break; 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: case utils::event_type::SET_AUDIO_POSITION:
{ {
auto d = std::any_cast<double>(e.m_data); auto d = std::any_cast<double>(e.m_data);

View File

@@ -33,6 +33,7 @@ namespace monitor::components
private: private:
void calculate_plugin(std::shared_ptr<utils::plugin> plugin); void calculate_plugin(std::shared_ptr<utils::plugin> plugin);
void change_tab(std::size_t index);
}; };
} }

View File

@@ -37,18 +37,27 @@ namespace monitor::components
m_snapshot_id = snapshot_id; m_snapshot_id = snapshot_id;
m_setup = setup; m_setup = setup;
calculate_plugin(m_base_plugins[0]);
m_graph.init(m_snapshot_id, m_setup); m_graph.init(m_snapshot_id, m_setup);
m_graph.set_plugin(m_base_plugins[0]);
// m_fft_scaled.init(m_snapshot_id, m_setup); // m_fft_scaled.init(m_snapshot_id, m_setup);
change_tab(0);
// send to: components/audio // send to: components/audio
VE::event e { utils::event_type::INIT_AUDIO, std::pair<std::string, utils::setup>(m_snapshot_id, m_setup) }; VE::event e { utils::event_type::INIT_AUDIO, std::pair<std::string, utils::setup>(m_snapshot_id, m_setup) };
EMIT(e); 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) void base_plugins::calculate_plugin(std::shared_ptr<utils::plugin> plugin)
{ {
if (!plugin->empty()) return; if (!plugin->empty()) return;
@@ -71,13 +80,8 @@ namespace monitor::components
if (!plugin->empty()) if (!plugin->empty())
{ {
plugin->init(); plugin->init(m_setup);
plugin->fill(); plugin->fill();
std::size_t compression = 1;
if (plugin->m_compression)
compression = plugin->m_compression_step;
m_setup.m_graph_compression = compression;
} }
else else
{ {

View File

@@ -11,11 +11,16 @@ namespace monitor::components
switch (type) switch (type)
{ {
// case utils::event_type::CREATE_SNAPSHOT_COMPLETED: case utils::event_type::PREPARE_BASE_PLUGIN_COMPRESSION:
// { {
// clear(); auto snapshot_id = std::any_cast<std::string>(e.m_data);
// break; 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,12 +22,7 @@ namespace monitor::components
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked()) change_tab(i);
{
m_current_open_index = i;
calculate_plugin(m_base_plugins[i]);
m_graph.set_plugin(m_base_plugins[i]);
}
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }

View File

@@ -6,6 +6,9 @@ namespace monitor::components
void tabs::on_attach() void tabs::on_attach()
{ {
CONNECT(this); CONNECT(this);
hack::log().on_full_path();
hack::log().set_devider(" = ");
} }
void tabs::on_detach() void tabs::on_detach()
@@ -41,8 +44,12 @@ namespace monitor::components
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE); m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
m_current_open_index = i; m_current_open_index = i;
// 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 // send to: components/audio
VE::event e { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id }; VE::event e1 { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id };
EMIT(e); EMIT(e1);
}; };
} }

View File

@@ -15,7 +15,7 @@ namespace monitor::libs
// сделать выбор устройства из интерфейса // сделать выбор устройства из интерфейса
// поставь, то которое есть в списке устройств // поставь, то которое есть в списке устройств
for (auto& d : devices) std::cout << d << std::endl; 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)) if (sf::PlaybackDevice::setDevice(target_device))
hack::log()("Устройство успешно установлено: ", target_device); hack::log()("Устройство успешно установлено: ", target_device);
else else

View File

@@ -10,7 +10,9 @@ namespace monitor::utils
STATUS_COMPLETED, STATUS_COMPLETED,
INIT_AUDIO, INIT_AUDIO,
CHANGE_AUDIO, CHANGE_AUDIO,
SET_COMPRESSION,
SET_MARKER_AUDIO_POSITION, SET_MARKER_AUDIO_POSITION,
PREPARE_BASE_PLUGIN_COMPRESSION,
/// делать /// делать

View File

@@ -51,7 +51,7 @@ namespace monitor::utils
public: public:
virtual bool empty() = 0; virtual bool empty() = 0;
virtual void init() = 0; virtual void init(hr::setup setup) = 0;
virtual void fill() = 0; virtual void fill() = 0;
virtual void set_ox(std::size_t start_pos = 0) = 0; virtual void set_ox(std::size_t start_pos = 0) = 0;
}; };

View File

@@ -8,7 +8,7 @@ namespace monitor::utils::plugins
m_display_name = "FFT"; m_display_name = "FFT";
} }
void fft::init() void fft::init(hr::setup setup)
{ {
try try
{ {

View File

@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
fft(); fft();
~fft() = default; ~fft() = default;
void init() override; void init(hr::setup setup) override;
void set_ox(std::size_t start_pos = 0) override; void set_ox(std::size_t start_pos = 0) override;
void fill() override; void fill() override;
bool empty() override; bool empty() override;

View File

@@ -8,13 +8,12 @@ namespace monitor::utils::plugins
m_display_name = "Magnitude"; m_display_name = "Magnitude";
} }
void magnitude::init() void magnitude::init(hr::setup setup)
{ {
try try
{ {
m_compression = m_result.m_size > m_size; m_size = m_result.m_size;
if (!m_compression) m_size = m_result.m_size; m_compression_step = setup.m_step_size;
m_line_count = m_result.m_data.size(); m_line_count = m_result.m_data.size();
m_line_data.reserve(m_line_count); 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)); for (std::size_t i = 0; i < m_line_count; ++i) m_line_data.push_back(hr::fvec_t(m_size, 0.f));
@@ -29,43 +28,16 @@ namespace monitor::utils::plugins
void magnitude::fill() void magnitude::fill()
{ {
if (m_compression) std::size_t line_count = 0;
for (auto el : m_result.m_data)
{ {
m_compression_step = m_result.m_size / m_size; std::size_t bin_index = 0;
for (auto e : el)
std::size_t line_count = 0;
for (auto& gd : m_line_data)
{ {
std::size_t bin_index = 0; m_line_data[line_count][bin_index] = e.m_value;
for (auto& g : gd) ++bin_index;
{
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;
} }
++line_count;
} }
} }

View File

@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
magnitude(); magnitude();
~magnitude() = default; ~magnitude() = default;
void init() override; void init(hr::setup setup) override;
void fill() override; void fill() override;
void set_ox(std::size_t start_pos = 0) override; void set_ox(std::size_t start_pos = 0) override;
bool empty() override; bool empty() override;

View File

@@ -8,7 +8,7 @@ namespace monitor::utils::plugins
m_display_name = "Raw Data"; m_display_name = "Raw Data";
} }
void raw_data::init() void raw_data::init(hr::setup setup)
{ {
try try
{ {

View File

@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
raw_data(); raw_data();
~raw_data() = default; ~raw_data() = default;
void init() override; void init(hr::setup setup) override;
void fill() override; void fill() override;
void set_ox(std::size_t start_pos = 0) override; void set_ox(std::size_t start_pos = 0) override;
bool empty() override; bool empty() override;

View File

@@ -6,9 +6,9 @@ namespace monitor::utils
{ {
struct setup : public hr::setup struct setup : public hr::setup
{ {
// это меняющеесе значение в зависимости от плагина, а не // // это меняющеесе значение в зависимости от плагина, а не
// как может показаться от аудио файла // // как может показаться от аудио файла
std::size_t m_graph_compression = 0; // std::size_t m_graph_compression = 0;
}; };
} }