fix compression
This commit is contained in:
@@ -23,6 +23,10 @@ namespace monitor::components
|
|||||||
} 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;
|
||||||
|
|
||||||
std::vector<std::string> m_domains = { "time", "frequensy"};
|
std::vector<std::string> m_domains = { "time", "frequensy"};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -51,7 +51,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();
|
||||||
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
|
// send to:: components/markers
|
||||||
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, current_sample_index };
|
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, current_sample_index };
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ namespace monitor::components
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case utils::event_type::SET_COMPRESSION:
|
||||||
|
{
|
||||||
|
auto c = std::any_cast<std::size_t>(e.m_data);
|
||||||
|
m_compression = c;
|
||||||
|
hack::log()(m_compression);
|
||||||
|
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);
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ namespace monitor::components
|
|||||||
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_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);
|
// m_fft_scaled.init(m_snapshot_id, m_setup);
|
||||||
|
|
||||||
// send to: components/audio
|
// send to: components/audio
|
||||||
@@ -75,6 +73,14 @@ namespace monitor::components
|
|||||||
{
|
{
|
||||||
plugin->init();
|
plugin->init();
|
||||||
plugin->fill();
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ namespace monitor::components
|
|||||||
{
|
{
|
||||||
case utils::event_type::INCREMENT_MARKER_AUDIO_POSITION:
|
case utils::event_type::INCREMENT_MARKER_AUDIO_POSITION:
|
||||||
{
|
{
|
||||||
auto t = std::any_cast<int>(e.m_data);
|
auto p = std::any_cast<double>(e.m_data);
|
||||||
|
m_marker_audio_position = p;
|
||||||
m_marker_audio_position = (double)t/11;
|
|
||||||
hack::log()(t, m_marker_audio_position);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace monitor::libs
|
|||||||
void audio::set_file(std::filesystem::path p)
|
void audio::set_file(std::filesystem::path p)
|
||||||
{
|
{
|
||||||
if (!m_music.openFromFile(p)) hack::error()("dont open file:", p.string());
|
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<void(sf::Time)> c)
|
void audio::set_callback(std::function<void(sf::Time)> c)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace monitor::utils
|
|||||||
STATUS_COMPLETED,
|
STATUS_COMPLETED,
|
||||||
INIT_AUDIO,
|
INIT_AUDIO,
|
||||||
CHANGE_AUDIO,
|
CHANGE_AUDIO,
|
||||||
|
SET_COMPRESSION,
|
||||||
|
|
||||||
|
|
||||||
/// делать
|
/// делать
|
||||||
|
|||||||
@@ -44,21 +44,24 @@ namespace monitor::utils
|
|||||||
std::vector<hr::fvec_t> m_line_data;
|
std::vector<hr::fvec_t> 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:
|
public:
|
||||||
virtual bool empty() { return m_result.empty(); }
|
virtual bool empty() { return m_result.empty(); }
|
||||||
|
|
||||||
|
// HERE
|
||||||
|
// начинаем тут
|
||||||
|
// перенести это все в папаки с плагинами т.е. код должен быть у каждого плагина
|
||||||
|
// т.к. m_compression_step у fft и у RAW_DATA работает по разному и это нужно учитывать
|
||||||
virtual void init()
|
virtual void init()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_comporession = m_result.m_size > m_size;
|
m_compression = m_result.m_size > m_size;
|
||||||
hack::log()(m_comporession);
|
if (!m_compression) m_size = m_result.m_size;
|
||||||
if (!m_comporession) m_size = m_result.m_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);
|
||||||
@@ -80,9 +83,9 @@ namespace monitor::utils
|
|||||||
|
|
||||||
virtual void fill()
|
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;
|
std::size_t line_count = 0;
|
||||||
for (auto& gd : m_line_data)
|
for (auto& gd : m_line_data)
|
||||||
@@ -91,17 +94,16 @@ namespace monitor::utils
|
|||||||
for (auto& g : gd)
|
for (auto& g : gd)
|
||||||
{
|
{
|
||||||
float tmp_e = 0.f;
|
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;
|
auto e = m_result.m_data[line_count][j].m_value;
|
||||||
tmp_e = hack::math::max_abs(e, tmp_e);
|
tmp_e = hack::math::max_abs(e, tmp_e);
|
||||||
}
|
}
|
||||||
g = 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;
|
if (bin_index > m_result.m_size) bin_index = m_result.m_size;
|
||||||
}
|
}
|
||||||
m_size = bin_index / m_comporession_step;
|
m_size = bin_index / m_compression_step;
|
||||||
hack::log()(m_comporession_step, m_size);
|
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace monitor::utils::plugins
|
|||||||
// для заполнения начальными данными
|
// для заполнения начальными данными
|
||||||
virtual void fill()
|
virtual void fill()
|
||||||
{
|
{
|
||||||
if (m_comporession) hack::error()("Данных больше чем можем отрисовать на экране, см. что-то с масштабированием...");
|
if (m_compression) hack::error()("Данных больше чем можем отрисовать на экране, см. что-то с масштабированием...");
|
||||||
|
|
||||||
std::size_t line_count = 0;
|
std::size_t line_count = 0;
|
||||||
for (auto el : m_result.m_data)
|
for (auto el : m_result.m_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user