summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeeJayLSP <djlsplays@gmail.com>2024-03-01 20:06:48 -0300
committerDeeJayLSP <djlsplays@gmail.com>2024-03-04 00:05:48 -0300
commit7fa3431dca962dd2ac9c628e69908b42705497e6 (patch)
treeaf3ab9697e9443a5985ed16adb061e36c9413fd0
parentdad6c774b019ef8c5dccb4a1955c6a77b41a323e (diff)
downloadredot-engine-7fa3431dca962dd2ac9c628e69908b42705497e6.tar.gz
WAV importer: use cubic interpolation on resampler
-rw-r--r--editor/import/resource_importer_wav.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index c97b6a7579..ab14a5f01d 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -328,7 +328,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
int ipos = 0;
for (int i = 0; i < new_data_frames; i++) {
- //simple cubic interpolation should be enough.
+ // Cubic interpolation should be enough.
float mu = frac;
@@ -337,15 +337,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
float y2 = data[MIN(frames - 1, ipos + 1) * format_channels + c];
float y3 = data[MIN(frames - 1, ipos + 2) * format_channels + c];
- float mu2 = mu * mu;
- float a0 = y3 - y2 - y0 + y1;
- float a1 = y0 - y1 - a0;
- float a2 = y2 - y0;
- float a3 = y1;
-
- float res = (a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3);
-
- new_data.write[i * format_channels + c] = res;
+ new_data.write[i * format_channels + c] = Math::cubic_interpolate(y1, y2, y0, y3, mu);
// update position and always keep fractional part within ]0...1]
// in order to avoid 32bit floating point precision errors