diff --git a/src/monitor/gui/components/audio/audio.hpp b/src/monitor/gui/components/audio/audio.hpp index 58d6b1b..e1e364a 100755 --- a/src/monitor/gui/components/audio/audio.hpp +++ b/src/monitor/gui/components/audio/audio.hpp @@ -23,6 +23,10 @@ namespace monitor::components } m_current_audio; std::map m_audio_data; + // это меняющеесе значение в зависимости от плагина, а не + // как может показаться от аудио файла + std::size_t m_compression; + std::vector m_domains = { "time", "frequensy"}; public: diff --git a/src/monitor/gui/components/audio/cpp/base.cpp b/src/monitor/gui/components/audio/cpp/base.cpp index d35bc47..e69e675 100755 --- a/src/monitor/gui/components/audio/cpp/base.cpp +++ b/src/monitor/gui/components/audio/cpp/base.cpp @@ -51,7 +51,7 @@ namespace monitor::components { m_current_audio.m_current_time = time; double seconds = time.asSeconds(); - int current_sample_index = (int)(seconds * m_current_audio.m_setup.m_sample_rate); + 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::INCREMENT_MARKER_AUDIO_POSITION, current_sample_index }; diff --git a/src/monitor/gui/components/audio/cpp/on_event.cpp b/src/monitor/gui/components/audio/cpp/on_event.cpp index 7227e0d..bbe8fc2 100755 --- a/src/monitor/gui/components/audio/cpp/on_event.cpp +++ b/src/monitor/gui/components/audio/cpp/on_event.cpp @@ -47,6 +47,14 @@ namespace monitor::components break; } + case utils::event_type::SET_COMPRESSION: + { + auto c = std::any_cast(e.m_data); + m_compression = c; + hack::log()(m_compression); + break; + } + case utils::event_type::SET_AUDIO_POSITION: { auto d = std::any_cast(e.m_data); diff --git a/src/monitor/gui/components/base_plugins/cpp/base.cpp b/src/monitor/gui/components/base_plugins/cpp/base.cpp index 872725f..de07b11 100644 --- a/src/monitor/gui/components/base_plugins/cpp/base.cpp +++ b/src/monitor/gui/components/base_plugins/cpp/base.cpp @@ -42,8 +42,6 @@ namespace monitor::components m_graph.init(m_snapshot_id, m_setup); m_graph.set_plugin(m_base_plugins[0]); - hack::log()(m_base_plugins[0]->m_result.m_size, m_setup.m_sample_rate); - // m_fft_scaled.init(m_snapshot_id, m_setup); // send to: components/audio @@ -75,6 +73,14 @@ namespace monitor::components { plugin->init(); plugin->fill(); + + std::size_t compression = 1; + if (plugin->m_compression) + compression = plugin->m_compression_step; + + // send to: components/audio + VE::event e { utils::event_type::SET_COMPRESSION, compression }; + EMIT(e); } else { diff --git a/src/monitor/gui/components/markers/cpp/on_event.cpp b/src/monitor/gui/components/markers/cpp/on_event.cpp index f25bbdb..71c2c0f 100644 --- a/src/monitor/gui/components/markers/cpp/on_event.cpp +++ b/src/monitor/gui/components/markers/cpp/on_event.cpp @@ -36,10 +36,8 @@ namespace monitor::components { case utils::event_type::INCREMENT_MARKER_AUDIO_POSITION: { - auto t = std::any_cast(e.m_data); - - m_marker_audio_position = (double)t/11; - hack::log()(t, m_marker_audio_position); + auto p = std::any_cast(e.m_data); + m_marker_audio_position = p; break; } diff --git a/src/monitor/libs/audio/audio.cpp b/src/monitor/libs/audio/audio.cpp index a00be18..70bc108 100644 --- a/src/monitor/libs/audio/audio.cpp +++ b/src/monitor/libs/audio/audio.cpp @@ -25,7 +25,6 @@ namespace monitor::libs void audio::set_file(std::filesystem::path p) { if (!m_music.openFromFile(p)) hack::error()("dont open file:", p.string()); - hack::log()("0", m_music.getDuration().asMicroseconds()); } void audio::set_callback(std::function c) diff --git a/src/monitor/utils/event_type.hpp b/src/monitor/utils/event_type.hpp index 00755f0..1a36b09 100644 --- a/src/monitor/utils/event_type.hpp +++ b/src/monitor/utils/event_type.hpp @@ -10,6 +10,7 @@ namespace monitor::utils STATUS_COMPLETED, INIT_AUDIO, CHANGE_AUDIO, + SET_COMPRESSION, /// делать diff --git a/src/monitor/utils/plugin.hpp b/src/monitor/utils/plugin.hpp index 8fb9739..f47e2e8 100644 --- a/src/monitor/utils/plugin.hpp +++ b/src/monitor/utils/plugin.hpp @@ -44,21 +44,24 @@ namespace monitor::utils std::vector m_line_data; // говорит нужно ли делать сжатие графика ли нет - bool m_comporession = false; + bool m_compression = false; // шаг сжатия - std::size_t m_comporession_step = 0; + std::size_t m_compression_step = 0; public: virtual bool empty() { return m_result.empty(); } + // HERE + // начинаем тут + // перенести это все в папаки с плагинами т.е. код должен быть у каждого плагина + // т.к. m_compression_step у fft и у RAW_DATA работает по разному и это нужно учитывать virtual void init() { try { - m_comporession = m_result.m_size > m_size; - hack::log()(m_comporession); - if (!m_comporession) m_size = m_result.m_size; + 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); @@ -80,9 +83,9 @@ namespace monitor::utils virtual void fill() { - if (m_comporession) + if (m_compression) { - m_comporession_step = m_result.m_size / m_size; + m_compression_step = m_result.m_size / m_size; std::size_t line_count = 0; for (auto& gd : m_line_data) @@ -91,17 +94,16 @@ namespace monitor::utils for (auto& g : gd) { float tmp_e = 0.f; - for (std::size_t j = bin_index - m_comporession_step; j < bin_index; ++j) + 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_comporession_step; + bin_index += m_compression_step; if (bin_index > m_result.m_size) bin_index = m_result.m_size; } - m_size = bin_index / m_comporession_step; - hack::log()(m_comporession_step, m_size); + m_size = bin_index / m_compression_step; ++line_count; } } diff --git a/src/monitor/utils/plugins/fft.hpp b/src/monitor/utils/plugins/fft.hpp index f76ebe0..8733109 100644 --- a/src/monitor/utils/plugins/fft.hpp +++ b/src/monitor/utils/plugins/fft.hpp @@ -43,7 +43,7 @@ namespace monitor::utils::plugins // для заполнения начальными данными virtual void fill() { - if (m_comporession) hack::error()("Данных больше чем можем отрисовать на экране, см. что-то с масштабированием..."); + if (m_compression) hack::error()("Данных больше чем можем отрисовать на экране, см. что-то с масштабированием..."); std::size_t line_count = 0; for (auto el : m_result.m_data)