Переглянути джерело

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.
kleines Filmröllchen 3 роки тому
батько
коміт
22b836dd7b

+ 2 - 1
Userland/Applications/Piano/Music.h

@@ -23,7 +23,8 @@ struct Sample {
     i16 right;
 };
 
-constexpr int sample_count = 1 << 9;
+// HACK: needs to increase with device sample rate, but all of the sample_count stuff is static for now
+constexpr int sample_count = 1 << 12;
 
 constexpr int buffer_size = sample_count * sizeof(Sample);
 

+ 4 - 1
Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp

@@ -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++) {