From 388ab13db1c2a10534a9b81acba8fef98d96409c Mon Sep 17 00:00:00 2001 From: Shane Nelson Date: Sat, 27 Jun 2015 17:45:31 -0400 Subject: [PATCH] Audio: new dsp_coef.bin with windowed sinc filter coefficients --- Data/Sys/GC/dsp_coef.bin | Bin 4096 -> 4096 bytes Source/Core/Core/DSP/DSPCore.cpp | 7 +++++-- docs/DSP/free_dsp_rom/dsp_rom_readme.txt | 13 ++++++++++++ docs/DSP/free_dsp_rom/generate_coefs.py | 25 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 docs/DSP/free_dsp_rom/generate_coefs.py diff --git a/Data/Sys/GC/dsp_coef.bin b/Data/Sys/GC/dsp_coef.bin index a276f2cede1a8e6936b4526f9621a391ca6b9515..1137fd741ec917caab4716a3ef5d8374ef246e5a 100644 GIT binary patch literal 4096 zcmeIu=U-Ikz6J1S@98kKq4(Z&051_4aFjgu3OBkGS@s)D4FbB(&?M zt~q8Sk)4?8a~wqWwnJ36lN7ny=2OR0Lul-lHc8AVzfsMRi+D8YIY zrF6N9#MaK#G*=mtTb-aHTz^3`ti+U!TQ(}Nyr-buMo^jM0>!9%KAJBA#VPlPs7|y~ zvDKptHHtzN)gI5$Cl=QfDV~eaW(%c4naVE)eKa+e`TF$|Y?ChOguk2+ znG{Le{cjT4jM%h(+nMm!R{$q) zyvEy^_Bg7Je9oJjwlZpp#pSuCnM60Re7F;-`=hliDff74bWAg=hPxtVAjZJj%uP)x zh;3nYagCB+#Ohh2ocqZu;u=|)b1<2VW7yuD`lK!K%h}U8k|ewMx9kRvWnz0m4ZEHF zJTV~Q8T%&tY{HL;#cVx$b3$z5T}}X78Gk-W!6{@X#HS_oayGIp;`);#IpS!CC@`@iI&V1H_BaH5n=+GvZdr$Bdti3W=VO#hI2y2Z@g0XPGLa zx5SshMVV)eQwVj??JU0WW@2HGEGysm5m6Y}o7FB1A!LEkS(CzbL~Ot@X_W9D;Tzx~ zZ88ZYZ2fmhdrj66e19_;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WjmCYX<|`&Y-q2q^%5V3nSXhs5UXCjf`sp6I#!t z)-k2EOlu7@TFtChF{fXc*Gd+&f<-N7Nz3@ErF_#8mbI7_En-y*`K|@5X+G}fjtn#O^C;!smL(iDE`M}BEC$C|{6CUU9?oM}Ag8pnmk za;YD<(ipBanj3x3twwRDk=*M$9yEeS4d+S2c-Bx}G~~7MZ!hS7t~mt#5BmRh2toft d?L)Bt!T!G;La_h;_WoP;;0qE668P^D_zP_)!utRK diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 54262ede66..bfe7c64b6c 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -42,7 +42,10 @@ static bool VerifyRoms() // delroth's improvement on LM1234 replacement ROM (Zelda and AX only, // IPL/Card/GBA still broken) - { 0xd9907f71, 0xb019c2fb } + { 0xd9907f71, 0xb019c2fb }, + + // above with improved resampling coefficients + { 0xd9907f71, 0xdb6880c1 } }; u32 hash_irom = HashAdler32((u8*)g_dsp.irom, DSP_IROM_BYTE_SIZE); @@ -69,7 +72,7 @@ static bool VerifyRoms() DSPHost::OSD_AddMessage("You are using an old free DSP ROM made by the Dolphin Team.", 6000); DSPHost::OSD_AddMessage("Only games using the Zelda UCode will work correctly.", 6000); } - else if (rom_idx == 2) + else if (rom_idx == 2 || rom_idx == 3) { DSPHost::OSD_AddMessage("You are using a free DSP ROM made by the Dolphin Team.", 8000); DSPHost::OSD_AddMessage("All Wii games will work correctly, and most GC games should ", 8000); diff --git a/docs/DSP/free_dsp_rom/dsp_rom_readme.txt b/docs/DSP/free_dsp_rom/dsp_rom_readme.txt index bcaa2eee43..7dc073a80b 100644 --- a/docs/DSP/free_dsp_rom/dsp_rom_readme.txt +++ b/docs/DSP/free_dsp_rom/dsp_rom_readme.txt @@ -1,3 +1,16 @@ +Legal GC/WII DSP IROM replacement (v0.2.1) +------------------------------------------------------- + +- coef: 4-tap polyphase FIR filters +- irom: unchanged + +Coefficients are roughly equivalent to those in the official DROM. +Improves resampling quality greatly over linear interpolation. +See generate_coefs.py for details. + +stgn +29/june/2015 + Legal GC/WII DSP IROM replacement (v0.2) ------------------------------------------------------- diff --git a/docs/DSP/free_dsp_rom/generate_coefs.py b/docs/DSP/free_dsp_rom/generate_coefs.py new file mode 100644 index 0000000000..5b1771429d --- /dev/null +++ b/docs/DSP/free_dsp_rom/generate_coefs.py @@ -0,0 +1,25 @@ +from numpy import * +from struct import pack + +def pack_coefs(c): + cw = list(zip(c[ :128][::-1], + c[128:256][::-1], + c[256:384][::-1], + c[384: ][::-1])) + m = max(sum(x) for x in cw) + return b''.join(pack('>4h', *(int(round(n / m * 32767)) for n in x)) for x in cw) + +x = linspace(-2, 2, 512, endpoint=False) + +w1 = hamming(512) +w2 = kaiser(512, pi * 9/4) + +coef_1 = [sinc(n * 0.5) for n in x] * w1 +coef_2 = [sinc(n * 0.75) for n in x] * w2 +coef_3 = [sinc(n) for n in x] * w1 + +with open('dsp_coef.bin', 'wb') as f: + f.write(pack_coefs(coef_1)) + f.write(pack_coefs(coef_2)) + f.write(pack_coefs(coef_3)) + f.write(b'\0' * 1024)