1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

Userland: Two low-sample rate fixes

1) The Sound Player visualizer couldn't deal with small sample buffers,
   which occur on low sample rates. Now, it simply doesn't update its
buffer, meaning the display is broken on low sample rates. I'm not too
familiar with the visualizer to figure out a proper fix for now, but
this mitigates the issue (and "normal" sample rates still work).
2) Piano wouldn't buffer enough samples for small sample rates, so the
   sample count per buffer is now increased to 2^12, introducing minor
amounts of (acceptable) lag.
This commit is contained in:
kleines Filmröllchen 2021-08-19 00:18:22 +02:00 committed by Ali Mohammad Pur
parent d049626f40
commit 22b836dd7b
2 changed files with 6 additions and 2 deletions

View file

@ -97,7 +97,10 @@ void BarsVisualizationWidget::set_buffer(RefPtr<Audio::Buffer> buffer, int sampl
if (m_is_using_last)
return;
m_is_using_last = true;
VERIFY(buffer->sample_count() >= 256);
// FIXME: We should dynamically adapt to the sample count and e.g. perform the fft over multiple buffers.
// For now, the visualizer doesn't work with extremely low global sample rates.
if (buffer->sample_count() < 256)
return;
m_sample_count = round_previous_power_of_2(samples_to_use);
m_sample_buffer.resize(m_sample_count);
for (int i = 0; i < m_sample_count; i++) {