Changes in src/mathutils.c [7c07af2:9499eefb]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r7c07af2 r9499eefb 27 27 #include "config.h" 28 28 29 #ifdef HAVE_ACCELERATE30 #include <Accelerate/Accelerate.h>31 #endif32 29 33 30 /** Window types */ … … 173 170 fvec_max (fvec_t * s) 174 171 { 175 #ifndef HAVE_ACCELERATE176 172 uint_t j; 177 173 smpl_t tmp = 0.0; … … 179 175 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 180 176 } 181 #else182 smpl_t tmp = 0.;183 #if !HAVE_AUBIO_DOUBLE184 vDSP_maxv(s->data, 1, &tmp, s->length);185 #else186 vDSP_maxvD(s->data, 1, &tmp, s->length);187 #endif188 #endif189 177 return tmp; 190 178 } … … 193 181 fvec_min (fvec_t * s) 194 182 { 195 #ifndef HAVE_ACCELERATE196 183 uint_t j; 197 184 smpl_t tmp = s->data[0]; … … 199 186 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 200 187 } 201 #else202 smpl_t tmp = 0.;203 #if !HAVE_AUBIO_DOUBLE204 vDSP_minv(s->data, 1, &tmp, s->length);205 #else206 vDSP_minvD(s->data, 1, &tmp, s->length);207 #endif208 #endif209 188 return tmp; 210 189 } … … 213 192 fvec_min_elem (fvec_t * s) 214 193 { 215 #ifndef HAVE_ACCELERATE216 194 uint_t j, pos = 0.; 217 195 smpl_t tmp = s->data[0]; … … 220 198 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 221 199 } 222 #else223 smpl_t tmp = 0.;224 uint_t pos = 0.;225 #if !HAVE_AUBIO_DOUBLE226 vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);227 #else228 vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);229 #endif230 #endif231 200 return pos; 232 201 } … … 235 204 fvec_max_elem (fvec_t * s) 236 205 { 237 #ifndef HAVE_ACCELERATE238 206 uint_t j, pos = 0; 239 207 smpl_t tmp = 0.0; … … 242 210 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 243 211 } 244 #else245 smpl_t tmp = 0.;246 uint_t pos = 0.;247 #if !HAVE_AUBIO_DOUBLE248 vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);249 #else250 vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);251 #endif252 #endif253 212 return pos; 254 213 } … … 409 368 } 410 369 370 smpl_t fvec_quadint (fvec_t * x, uint_t pos) { 371 smpl_t s0, s1, s2; 372 uint_t x0 = (pos < 1) ? pos : pos - 1; 373 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos; 374 if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2; 375 if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0; 376 s0 = x->data[x0]; 377 s1 = x->data[pos]; 378 s2 = x->data[x2]; 379 return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0); 380 } 381 411 382 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) { 412 383 smpl_t s0, s1, s2; 413 if (pos == 0 || pos == x->length - 1) return pos;414 384 uint_t x0 = (pos < 1) ? pos : pos - 1; 415 385 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
Note: See TracChangeset
for help on using the changeset viewer.