diff options
author | musil <tmusil@users.sourceforge.net> | 2015-03-06 17:47:38 +0000 |
---|---|---|
committer | musil <tmusil@users.sourceforge.net> | 2015-03-06 17:47:38 +0000 |
commit | 65a9afa3bf17ba83670acc3fee4f18ea8efb5402 (patch) | |
tree | 4c88ce66685ed8f02b818079d199bc52298d2639 | |
parent | e3572a62146494841505a42c20821f11f9cd5d11 (diff) |
update sqrt algo to millers exported q8_sqrtHEADsvn2git-headexternals/iem/iem_spec2
svn path=/trunk/externals/iem/iem_spec2/; revision=17435
-rw-r--r-- | src/makefile_vc9proj | 13 | ||||
-rw-r--r-- | src/spec2_sqrt~.c | 60 |
2 files changed, 20 insertions, 53 deletions
diff --git a/src/makefile_vc9proj b/src/makefile_vc9proj index e2e8205..1d07adb 100644 --- a/src/makefile_vc9proj +++ b/src/makefile_vc9proj @@ -2,11 +2,11 @@ TARGET = iem_spec2 all: ..\$(TARGET).dll
-VIS_CPP_PATH = "C:\Program Files\Microsoft Visual Studio 9.0\VC"
-VIS_SDK_PATH = "C:\Program Files\Microsoft SDKs\Windows\v6.0A"
-PD_INST_PATH = "C:\Program Files\pd-0.43.0"
-PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include
-PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -D_CRT_SECURE_NO_WARNINGS
+VIS_CPP_PATH = "$(PROGRAMFILES)\Microsoft Visual Studio 9.0\VC"
+VIS_SDK_PATH = "$(PROGRAMFILES)\Microsoft SDKs\Windows\v6.0A"
+PD_INST_PATH = "$(PROGRAMFILES)\pd"
+PD_WIN_INCLUDE_PATH = /I. /I..\..\include /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include
+PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /DHAVE_G_CANVAS_H /Ox -D_CRT_SECURE_NO_WARNINGS
PD_WIN_L_FLAGS = /nologo
PD_WIN_LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel32 \
@@ -38,7 +38,8 @@ SRC = spec2_1p1z_freq~.c \ spec2_tab_conv~.c \
spec2_tabreceive_enable~.c \
spec2_tabreceive~.c \
- iem_spec2.c
+ $(TARGET).c
+
OBJ = $(SRC:.c=.obj)
diff --git a/src/spec2_sqrt~.c b/src/spec2_sqrt~.c index 275b9b0..6f25ee1 100644 --- a/src/spec2_sqrt~.c +++ b/src/spec2_sqrt~.c @@ -11,34 +11,6 @@ iem_spec2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 200 static t_class *spec2_sqrt_tilde_class; -#define SPEC2DUMTAB1SIZE 256 -#define SPEC2DUMTAB2SIZE 1024 - -static t_float spec2_rsqrt_exptab[SPEC2DUMTAB1SIZE], spec2_rsqrt_mantissatab[SPEC2DUMTAB2SIZE]; - -static void init_spec2_rsqrt(void) -{ -#ifndef __x86_64__ - int i; - - for (i=0; i<SPEC2DUMTAB1SIZE; i++) - { - t_float f; - long l = (i ? (i == SPEC2DUMTAB1SIZE-1 ? SPEC2DUMTAB1SIZE-2 : i) : 1)<< 23; - - *(long *)(&f) = l; - spec2_rsqrt_exptab[i] = 1.0f/sqrt(f); - } - - for (i=0; i<SPEC2DUMTAB2SIZE; i++) - { - t_float f = 1.0f + (1.0f / (t_float)SPEC2DUMTAB2SIZE) * (t_float)i; - - spec2_rsqrt_mantissatab[i] = 1.0f / sqrt(f); - } -#endif -} - typedef struct _spec2_sqrt_tilde { t_object x_obj; @@ -52,27 +24,23 @@ static t_int *spec2_sqrt_tilde_perform(t_int *w) int n = w[3]+1; while(n--) - { -#ifdef __x86_64__ + { t_sample f = *in++; - if (f<0.f) { - *out++=0.f; - } else { - *out++=sqrtf(f); + + if (f<0.0) + { + *out++=0.0; } + else + { +#if ((defined PD_MAJOR_VERSION && defined PD_MINOR_VERSION) && (PD_MAJOR_VERSION > 0 || PD_MINOR_VERSION > 43)) + t_float g = q8_rsqrt(f); + + *out++ = f*g*(1.5 - 0.5 * g * g * f); #else - t_float f = *in; - long l = *(long *)(in++); - - if(f < 0.0f) - *out++ = 0.0f; - else - { - t_float g = spec2_rsqrt_exptab[(l >> 23) & 0xff] * spec2_rsqrt_mantissatab[(l >> 13) & 0x3ff]; - - *out++ = f*g*(1.5f - 0.5f*g*g*f); - } + *out++ = sqrt(f); #endif + } } return(w+4); } @@ -95,10 +63,8 @@ static void *spec2_sqrt_tilde_new(void) void spec2_sqrt_tilde_setup(void) { - init_spec2_rsqrt(); spec2_sqrt_tilde_class = class_new(gensym("spec2_sqrt~"), (t_newmethod)spec2_sqrt_tilde_new, 0, sizeof(t_spec2_sqrt_tilde), 0, 0); CLASS_MAINSIGNALIN(spec2_sqrt_tilde_class, t_spec2_sqrt_tilde, x_msi); class_addmethod(spec2_sqrt_tilde_class, (t_method)spec2_sqrt_tilde_dsp, gensym("dsp"), 0); -// class_sethelpsymbol(spec2_sqrt_tilde_class, gensym("iemhelp2/spec2_sqrt~-help")); } |