add mark positions completed
This commit is contained in:
@@ -23,6 +23,7 @@ namespace monitor::components
|
||||
utils::setup m_setup;
|
||||
} m_current_audio;
|
||||
std::map<std::string, music> m_audio_data;
|
||||
std::size_t m_compression = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace monitor::components
|
||||
{
|
||||
m_current_audio.m_current_time = time;
|
||||
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
|
||||
VE::event e { utils::event_type::SET_MARKER_AUDIO_POSITION, current_sample_index };
|
||||
|
||||
@@ -46,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);
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace monitor::components
|
||||
|
||||
private:
|
||||
void calculate_plugin(std::shared_ptr<utils::plugin> plugin);
|
||||
void change_tab(std::size_t index);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,18 +37,27 @@ namespace monitor::components
|
||||
m_snapshot_id = snapshot_id;
|
||||
m_setup = setup;
|
||||
|
||||
calculate_plugin(m_base_plugins[0]);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
@@ -71,13 +80,8 @@ namespace monitor::components
|
||||
|
||||
if (!plugin->empty())
|
||||
{
|
||||
plugin->init();
|
||||
plugin->init(m_setup);
|
||||
plugin->fill();
|
||||
|
||||
std::size_t compression = 1;
|
||||
if (plugin->m_compression)
|
||||
compression = plugin->m_compression_step;
|
||||
m_setup.m_graph_compression = compression;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,7 @@ namespace monitor::components
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
m_current_open_index = i;
|
||||
calculate_plugin(m_base_plugins[i]);
|
||||
m_graph.set_plugin(m_base_plugins[i]);
|
||||
}
|
||||
if (ImGui::IsItemClicked()) change_tab(i);
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
@@ -41,8 +44,12 @@ namespace monitor::components
|
||||
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
|
||||
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
|
||||
VE::event e { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id };
|
||||
EMIT(e);
|
||||
VE::event e1 { utils::event_type::CHANGE_AUDIO, m_snapshots[i]->m_snapshot_id };
|
||||
EMIT(e1);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace monitor::utils
|
||||
STATUS_COMPLETED,
|
||||
INIT_AUDIO,
|
||||
CHANGE_AUDIO,
|
||||
SET_COMPRESSION,
|
||||
SET_MARKER_AUDIO_POSITION,
|
||||
PREPARE_BASE_PLUGIN_COMPRESSION,
|
||||
|
||||
|
||||
/// делать
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace monitor::utils
|
||||
|
||||
public:
|
||||
virtual bool empty() = 0;
|
||||
virtual void init() = 0;
|
||||
virtual void init(hr::setup setup) = 0;
|
||||
virtual void fill() = 0;
|
||||
virtual void set_ox(std::size_t start_pos = 0) = 0;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace monitor::utils::plugins
|
||||
m_display_name = "FFT";
|
||||
}
|
||||
|
||||
void fft::init()
|
||||
void fft::init(hr::setup setup)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
|
||||
fft();
|
||||
~fft() = default;
|
||||
|
||||
void init() override;
|
||||
void init(hr::setup setup) override;
|
||||
void set_ox(std::size_t start_pos = 0) override;
|
||||
void fill() override;
|
||||
bool empty() override;
|
||||
|
||||
@@ -8,13 +8,12 @@ namespace monitor::utils::plugins
|
||||
m_display_name = "Magnitude";
|
||||
}
|
||||
|
||||
void magnitude::init()
|
||||
void magnitude::init(hr::setup setup)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_compression = m_result.m_size > m_size;
|
||||
if (!m_compression) m_size = m_result.m_size;
|
||||
|
||||
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));
|
||||
@@ -29,43 +28,16 @@ namespace monitor::utils::plugins
|
||||
|
||||
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 line_count = 0;
|
||||
for (auto& gd : m_line_data)
|
||||
std::size_t bin_index = 0;
|
||||
for (auto e : el)
|
||||
{
|
||||
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;
|
||||
m_line_data[line_count][bin_index] = e.m_value;
|
||||
++bin_index;
|
||||
}
|
||||
++line_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
|
||||
magnitude();
|
||||
~magnitude() = default;
|
||||
|
||||
void init() override;
|
||||
void init(hr::setup setup) override;
|
||||
void fill() override;
|
||||
void set_ox(std::size_t start_pos = 0) override;
|
||||
bool empty() override;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace monitor::utils::plugins
|
||||
m_display_name = "Raw Data";
|
||||
}
|
||||
|
||||
void raw_data::init()
|
||||
void raw_data::init(hr::setup setup)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace monitor::utils::plugins
|
||||
raw_data();
|
||||
~raw_data() = default;
|
||||
|
||||
void init() override;
|
||||
void init(hr::setup setup) override;
|
||||
void fill() override;
|
||||
void set_ox(std::size_t start_pos = 0) override;
|
||||
bool empty() override;
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace monitor::utils
|
||||
{
|
||||
struct setup : public hr::setup
|
||||
{
|
||||
// это меняющеесе значение в зависимости от плагина, а не
|
||||
// как может показаться от аудио файла
|
||||
std::size_t m_graph_compression = 0;
|
||||
// // это меняющеесе значение в зависимости от плагина, а не
|
||||
// // как может показаться от аудио файла
|
||||
// std::size_t m_graph_compression = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user