From 65a9afa3bf17ba83670acc3fee4f18ea8efb5402 Mon Sep 17 00:00:00 2001 From: musil Date: Fri, 6 Mar 2015 17:47:38 +0000 Subject: update sqrt algo to millers exported q8_sqrt svn path=/trunk/externals/iem/iem_spec2/; revision=17435 --- src/makefile_vc9proj | 13 ++++++------ 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 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")); } -- cgit v1.2.1