Files
soothe2-re/dsp/freqpath.hpp
T

29 lines
1.3 KiB
C++

#pragma once
#include <cstddef>
#include <cstdint>
// Freq-path (FUN_180530850) warp and resonance-vs-warp product.
//
// WARP 0x5406a8 (peak builder loop @0x530900, disasm f530850_full.dis):
// K = expf(2.0723267f) (0x1824c4208 -> call 0x1a14cac)
// F = (2000.0f / (fs_total * 0.5f)) * (float)N (0x1824c45b4 / [0x24]*0x24c3d8c,
// scaled by (count/2+1) = N)
// for i in 1..N-1:
// x = (float)i / F (bin freq i ~ f = i*sr*0.5/N -> x ~ f/2000)
// r = 1.0f / (x / K + 1.0f) (0x1824c3ea4 = 1.0)
// r = (float)fabs((double)r) (cvtss2sd + andpd 0x24c4f10 + cvtpd2ps)
// w[i] = r * x
// w[0..N) *= 0.87f (0x1824c3e50), 0x5406a8[0] = 0 (0x24c4110 = 0.87 as double)
//
// warp(500)=0.211 warp(1000)=0.409 warp(2000)=0.773 (fs=44100)
//
// FUN_180530850 then applies the twin resonance (fc=8000.0, Q=1.0, sens c42d0=3.0
// via generator 0x180533ec0 + kernel 0x180535880) into 0x5406f8 and multiplies
// 0x5406f8 *= 0x5406a8 (thunk window-multiply 0x52d990). warp[0]=0 zeroes DC.
namespace detkernel {
// Build the 0x5406a8 warp (float, N bins, DC = 0).
void build_warp(float fs_total, int n, float* warp);
} // namespace detkernel