2 SuperCollider real time audio synthesis system
3 Copyright (c) 2003 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #if defined(HAS_ALTIVEC) || defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__)
27 You are allowed to undef these for C++ compatibility. */
35 typedef vector
signed int vint32
;
36 typedef vector
unsigned int vuint32
;
37 typedef vector
float vfloat32
;
39 // Since gcc 3.3 vector initializers are surrounded by brackets. <sk>
40 #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
41 # define vinit(x) { x, x, x, x }
43 # define vinit(x) ( x )
46 //#define vload(x) (*vtempptr = (x), vec_splat(vtemp,0))
47 #define define_vtemp vfloat32 vtemp; float *vtempptr = (float*)&vtemp;
48 #define define_vones vfloat32 vones = vec_ctf(vec_splat_s32(1),0);
49 #define define_vzero vfloat32 vzero = (vfloat32)vec_splat_s32(0);
50 #define vi0123 (vec_unpackh(vec_unpackh((vector signed char)vec_lvsl(0,(int*)0))))
51 #define v0123 (vec_ctf(vec_unpackh(vec_unpackh((vector signed char)vec_lvsl(0,(int*)0))), 0))
52 #define v0123_4ths (vec_ctf(vec_unpackh(vec_unpackh((vector signed char)vec_lvsl(0,(int*)0))), 2))
53 #define vstart(x, vslope) (vec_madd(vslope, v0123_4ths, vload(x)))
55 inline vint32
vec_not(vint32 arg
)
57 return vec_nor(arg
, arg
);
60 inline vfloat32
vec_not(vfloat32 arg
)
62 return vec_nor(arg
, arg
);
65 inline vfloat32
vec_mul(vfloat32 a
, vfloat32 b
)
68 return vec_madd(a
, b
, vzero
);
71 #define vec_2sComp(x) (vec_sub(vec_sub (x, x), x))
73 #define USEVEC (ft->mAltivecAvailable && !(BUFLENGTH & 3))
75 typedef union vec_union
{
82 inline vfloat32
vload( float f
)
86 return vec_splat( vec_lde( 0, temp
.f
), 0 );
89 inline vint32
vload( int32 i
)
93 return vec_splat( vec_lde( 0, temp
.i
), 0 );
96 inline vint32
vload( int32 a
, int32 b
, int32 c
, int32 d
)
106 inline vector
float vec_float_1( void )
108 return vec_ctf( vec_splat_u32(1), 0);
111 inline vector
float vec_reciprocal( vector
float v
)
113 vector
float reciprocal
= vec_re( v
);
114 return vec_madd( reciprocal
, vec_nmsub( reciprocal
, v
, vec_float_1()), reciprocal
); //Newton Rapheson refinement
118 // seed = ((seed & mask) << shift1) ^ (((seed << shift2) ^ seed) >> shift3);
120 #define define_trshifts \
121 vuint32 trmask = ((vuint32)(0xFFFFFFFE,0xFFFFFFF8,0xFFFFFFF0,0)); \
122 vuint32 trshift1 = ((vuint32)(12, 14, 7, 0)); \
123 vuint32 trshift2 = ((vuint32)(13, 2, 3, 0)); \
124 vuint32 trshift3 = ((vuint32)(19, 25, 11, 0));
126 inline vuint32
trands(vuint32 seed
, vuint32 trmask
, vuint32 shift1
, vuint32 shift2
, vuint32 shift3
)
128 return vec_xor(vec_sl(vec_and(seed
, trmask
),shift1
), vec_sr(vec_xor(vec_sl(seed
,shift2
),seed
),shift3
));