Changeset dc467b5d for src/mathutils.c
- Timestamp:
- Oct 27, 2013, 12:44:29 PM (10 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 8247249
- Parents:
- dd15573 (diff), 7fc5ba2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
rdd15573 rdc467b5d 27 27 #include "config.h" 28 28 29 #ifdef HAVE_ACCELERATE 30 #include <Accelerate/Accelerate.h> 31 #endif 29 32 30 33 /** Window types */ … … 170 173 fvec_max (fvec_t * s) 171 174 { 175 #ifndef HAVE_ACCELERATE 172 176 uint_t j; 173 177 smpl_t tmp = 0.0; … … 175 179 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 176 180 } 181 #else 182 smpl_t tmp = 0.; 183 #if !HAVE_AUBIO_DOUBLE 184 vDSP_maxv(s->data, 1, &tmp, s->length); 185 #else 186 vDSP_maxvD(s->data, 1, &tmp, s->length); 187 #endif 188 #endif 177 189 return tmp; 178 190 } … … 181 193 fvec_min (fvec_t * s) 182 194 { 195 #ifndef HAVE_ACCELERATE 183 196 uint_t j; 184 197 smpl_t tmp = s->data[0]; … … 186 199 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 187 200 } 201 #else 202 smpl_t tmp = 0.; 203 #if !HAVE_AUBIO_DOUBLE 204 vDSP_minv(s->data, 1, &tmp, s->length); 205 #else 206 vDSP_minvD(s->data, 1, &tmp, s->length); 207 #endif 208 #endif 188 209 return tmp; 189 210 } … … 192 213 fvec_min_elem (fvec_t * s) 193 214 { 215 #ifndef HAVE_ACCELERATE 194 216 uint_t j, pos = 0.; 195 217 smpl_t tmp = s->data[0]; … … 198 220 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 199 221 } 222 #else 223 smpl_t tmp = 0.; 224 uint_t pos = 0.; 225 #if !HAVE_AUBIO_DOUBLE 226 vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 227 #else 228 vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 229 #endif 230 #endif 200 231 return pos; 201 232 } … … 204 235 fvec_max_elem (fvec_t * s) 205 236 { 237 #ifndef HAVE_ACCELERATE 206 238 uint_t j, pos = 0; 207 239 smpl_t tmp = 0.0; … … 210 242 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 211 243 } 244 #else 245 smpl_t tmp = 0.; 246 uint_t pos = 0.; 247 #if !HAVE_AUBIO_DOUBLE 248 vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 249 #else 250 vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 251 #endif 252 #endif 212 253 return pos; 213 254 } … … 368 409 } 369 410 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 382 411 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) { 383 412 smpl_t s0, s1, s2; 413 if (pos == 0 || pos == x->length - 1) return pos; 384 414 uint_t x0 = (pos < 1) ? pos : pos - 1; 385 415 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
Note: See TracChangeset
for help on using the changeset viewer.