Update of /cvsroot/pure-data/externals/zexy/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30140/src
Modified Files: z_zexy.c z_zexy.h Added Files: absgn~.c Log Message: added [absgn~] as external (written by tim blechmann) and abstraction the main purpose of this external is speed
Index: z_zexy.h =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/z_zexy.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** z_zexy.h 21 Dec 2005 17:05:47 -0000 1.5 --- z_zexy.h 5 Jan 2006 11:53:24 -0000 1.6 *************** *** 7,10 **** --- 7,11 ---- #define Z_ZEXY_H__ void z_a2l_setup(void); /* a2l.c */ + void z_absgn__setup(void); /* absgn~.c */ void z_abs__setup(void); /* abs~.c */ void z_atoi_setup(void); /* atoi.c */ *************** *** 13,18 **** void z_blockswap__setup(void); /* blockswap~.c */ void z_date_setup(void); /* date.c */ - void z_demultiplex__setup(void); /* demultiplex~.c */ void z_demultiplex_setup(void); /* demultiplex.c */ void z_dfreq__setup(void); /* dfreq~.c */ void z_dirac__setup(void); /* dirac~.c */ --- 14,19 ---- void z_blockswap__setup(void); /* blockswap~.c */ void z_date_setup(void); /* date.c */ void z_demultiplex_setup(void); /* demultiplex.c */ + void z_demultiplex__setup(void); /* demultiplex~.c */ void z_dfreq__setup(void); /* dfreq~.c */ void z_dirac__setup(void); /* dirac~.c */ *************** *** 35,46 **** void z_msgfile_setup(void); /* msgfile.c */ void z_multiline__setup(void); /* multiline~.c */ - void z_multiplex__setup(void); /* multiplex~.c */ void z_multiplex_setup(void); /* multiplex.c */ void z_niagara_setup(void); /* niagara.c */ void z_noish__setup(void); /* noish~.c */ void z_noisi__setup(void); /* noisi~.c */ void z_operating_system_setup(void); /* operating_system.c */ - void z_pack__setup(void); /* pack~.c */ void z_packel_setup(void); /* packel.c */ void z_pdf__setup(void); /* pdf~.c */ void z_prime_setup(void); /* prime.c */ --- 36,47 ---- void z_msgfile_setup(void); /* msgfile.c */ void z_multiline__setup(void); /* multiline~.c */ void z_multiplex_setup(void); /* multiplex.c */ + void z_multiplex__setup(void); /* multiplex~.c */ void z_niagara_setup(void); /* niagara.c */ void z_noish__setup(void); /* noish~.c */ void z_noisi__setup(void); /* noisi~.c */ void z_operating_system_setup(void); /* operating_system.c */ void z_packel_setup(void); /* packel.c */ + void z_pack__setup(void); /* pack~.c */ void z_pdf__setup(void); /* pdf~.c */ void z_prime_setup(void); /* prime.c */ *************** *** 69,74 **** void z_winNT_portio_setup(void); /* winNT_portio.c */ void z_wrap_setup(void); /* wrap.c */ - void z_z__setup(void); /* z~.c */ void z_z_sigbin_setup(void); /* z_sigbin.c */ #endif /* Z_ZEXY_H__ */
--- 70,75 ---- void z_winNT_portio_setup(void); /* winNT_portio.c */ void z_wrap_setup(void); /* wrap.c */ void z_z_sigbin_setup(void); /* z_sigbin.c */ + void z_z__setup(void); /* z~.c */ #endif /* Z_ZEXY_H__ */
Index: z_zexy.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/z_zexy.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** z_zexy.c 21 Dec 2005 17:05:47 -0000 1.5 --- z_zexy.c 5 Jan 2006 11:53:24 -0000 1.6 *************** *** 9,12 **** --- 9,13 ---- { z_a2l_setup(); /* a2l.c */ + z_absgn__setup(); /* absgn~.c */ z_abs__setup(); /* abs~.c */ z_atoi_setup(); /* atoi.c */ *************** *** 15,20 **** z_blockswap__setup(); /* blockswap~.c */ z_date_setup(); /* date.c */ - z_demultiplex__setup(); /* demultiplex~.c */ z_demultiplex_setup(); /* demultiplex.c */ z_dfreq__setup(); /* dfreq~.c */ z_dirac__setup(); /* dirac~.c */ --- 16,21 ---- z_blockswap__setup(); /* blockswap~.c */ z_date_setup(); /* date.c */ z_demultiplex_setup(); /* demultiplex.c */ + z_demultiplex__setup(); /* demultiplex~.c */ z_dfreq__setup(); /* dfreq~.c */ z_dirac__setup(); /* dirac~.c */ *************** *** 37,48 **** z_msgfile_setup(); /* msgfile.c */ z_multiline__setup(); /* multiline~.c */ - z_multiplex__setup(); /* multiplex~.c */ z_multiplex_setup(); /* multiplex.c */ z_niagara_setup(); /* niagara.c */ z_noish__setup(); /* noish~.c */ z_noisi__setup(); /* noisi~.c */ z_operating_system_setup(); /* operating_system.c */ - z_pack__setup(); /* pack~.c */ z_packel_setup(); /* packel.c */ z_pdf__setup(); /* pdf~.c */ z_prime_setup(); /* prime.c */ --- 38,49 ---- z_msgfile_setup(); /* msgfile.c */ z_multiline__setup(); /* multiline~.c */ z_multiplex_setup(); /* multiplex.c */ + z_multiplex__setup(); /* multiplex~.c */ z_niagara_setup(); /* niagara.c */ z_noish__setup(); /* noish~.c */ z_noisi__setup(); /* noisi~.c */ z_operating_system_setup(); /* operating_system.c */ z_packel_setup(); /* packel.c */ + z_pack__setup(); /* pack~.c */ z_pdf__setup(); /* pdf~.c */ z_prime_setup(); /* prime.c */ *************** *** 71,76 **** z_winNT_portio_setup(); /* winNT_portio.c */ z_wrap_setup(); /* wrap.c */ - z_z__setup(); /* z~.c */ z_z_sigbin_setup(); /* z_sigbin.c */ }
--- 72,77 ---- z_winNT_portio_setup(); /* winNT_portio.c */ z_wrap_setup(); /* wrap.c */ z_z_sigbin_setup(); /* z_sigbin.c */ + z_z__setup(); /* z~.c */ }
--- NEW FILE: absgn~.c --- /****************************************************** * * zexy - implementation file * * (c) 2006 Tim Blechmann * * ****************************************************** * * license: GNU General Public License v.2 * ******************************************************/
#include "zexy.h"
typedef struct _absgn { t_object x_obj; float x_f; } t_absgn;
/* ------------------------ sigABSGN~ ----------------------------- */
static t_class *sigABSGN_class;
static t_int *sigABSGN_perform(t_int *w) { t_float *in = (t_float *)(w[1]); t_float *out = (t_float *)(w[2]); t_float *out2 = (t_float *)(w[3]); int n = (int)(w[4]);
while (n--) { t_float val = *in++; *out++ = fabsf(val);
if (val>0.) *out2++=1.; else if (val<0.) *out2++=-1.; else *out2++=0.; }
return (w+5); }
#ifdef __SSE__ static long l_bitmask[] ={0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; static long l_sgnbitmask[]={0x80000000, 0x80000000, 0x80000000, 0x80000000}; static t_int *sigABSGN_performSSE(t_int *w) { __m128 *in = (__m128 *)(w[1]); __m128 *out1 = (__m128 *)(w[2]); __m128 *out2 = (__m128 *)(w[3]); int n = (int)(w[4])>>3;
const __m128 bitmask= _mm_loadu_ps((float*)l_bitmask); const __m128 sgnmask= _mm_loadu_ps((float*)l_sgnbitmask); const __m128 zero = _mm_setzero_ps(); const __m128 one = _mm_set1_ps(1.f);
do { __m128 val, val2, xmm0, xmm1, xmm2, xmm3; val=in[0]; xmm0 = _mm_cmpneq_ps(val, zero); /* mask for non-zeros */ xmm1 = _mm_and_ps (val, sgnmask);/* sign (without value) */ xmm0 = _mm_and_ps (xmm0, one); /* (abs) value: (val==0.f)?0.f:1.f */ out1[0]= _mm_and_ps (val, bitmask);/* abs: set sign-bit to "+" */ out2[0]= _mm_or_ps (xmm1, xmm0); /* merge sign and value */
val2=in[1]; xmm2 = _mm_cmpneq_ps(val2, zero); /* mask for non-zeros */ xmm3 = _mm_and_ps (val2, sgnmask);/* sign (without value) */ xmm2 = _mm_and_ps (xmm2, one); /* (abs) value: (val==0.f)?0.f:1.f */ out1[1]= _mm_and_ps (val2, bitmask);/* abs: set sign-bit to "+" */ out2[1]= _mm_or_ps (xmm3, xmm2); /* merge sign and value */
in +=2; out+=2; out2+=2; } while (--n);
return (w+5); } #endif /* __SSE__ */
static void sigABSGN_dsp(t_absgn *x, t_signal **sp) { #ifdef __SSE__ if( Z_SIMD_CHKBLOCKSIZE(sp[0]->s_n)&& Z_SIMD_CHKALIGN(sp[0]->s_vec)&& Z_SIMD_CHKALIGN(sp[1]->s_vec)&& Z_SIMD_CHKALIGN(sp[2]->s_vec) ) { dsp_add(sigABSGN_performSSE, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } else #endif { dsp_add(sigABSGN_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } }
static void sigABSGN_helper(void) { post("\n%c absgn~ \t\t:: absolute value and sign of a signal", HEARTSYMBOL); post(" \t\t copyright (c) Tim Blechmann 2006"); }
static void *sigABSGN_new(void) { t_absgn *x = (t_absgn *)pd_new(sigABSGN_class); x->x_f=0.f;
outlet_new(&x->x_obj, gensym("signal")); outlet_new(&x->x_obj, gensym("signal"));
return (x); }
void absgn_tilde_setup(void) { sigABSGN_class = class_new(gensym("absgn~"), (t_newmethod)sigABSGN_new, 0, sizeof(t_absgn), 0, A_DEFFLOAT, 0); CLASS_MAINSIGNALIN(sigABSGN_class, t_absgn, x_f); class_addmethod(sigABSGN_class, (t_method)sigABSGN_dsp, gensym("dsp"), 0);
class_addmethod(sigABSGN_class, (t_method)sigABSGN_helper, gensym("help"), 0); class_sethelpsymbol(sigABSGN_class, gensym("zexy/sigbinops+"));
zexy_register("absgn~"); }
void z_absgn__setup(void) { absgn_tilde_setup(); }