Jelajahi Sumber

LibDSP+LibAudio: Use logarithmic scaling in delay effect

With logarithmic volume scaling, the delay effect can sound more
natural.
kleines Filmröllchen 3 tahun lalu
induk
melakukan
ab4a2b8b41

+ 1 - 1
Userland/Libraries/LibAudio/Buffer.h

@@ -78,7 +78,7 @@ struct Frame {
         return *this;
     }
 
-    ALWAYS_INLINE Frame log_multiplied(double const volume_change)
+    ALWAYS_INLINE Frame log_multiplied(double const volume_change) const
     {
         Frame new_frame { left, right };
         new_frame.log_multiply(volume_change);

+ 2 - 3
Userland/Libraries/LibDSP/Effects.cpp

@@ -39,9 +39,8 @@ Signal Delay::process_impl(Signal const& input_signal)
 
     Sample const& in = input_signal.get<Sample>();
     Sample out;
-    // FIXME: Once we have log scaling, change these to use it instead
-    out += in.scaled(static_cast<double>(m_dry_gain));
-    out += m_delay_buffer[m_delay_index].scaled(m_delay_decay);
+    out += in.log_multiplied(static_cast<double>(m_dry_gain));
+    out += m_delay_buffer[m_delay_index].log_multiplied(m_delay_decay);
 
     // This is also convenient for disabling the delay effect by setting the buffer size to 0
     if (m_delay_buffer.size() >= 1)