- Timestamp:
- Apr 8, 2013, 5:19:10 PM (12 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:
- 69d642a
- Parents:
- 002563f
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r002563f r9499eefb 1 1 /* 2 Copyright (C) 2003-20 09Paul Brossier <piem@aubio.org>2 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> 3 3 4 4 This file is part of aubio. … … 380 380 } 381 381 382 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) { 383 smpl_t s0, s1, s2; 384 uint_t x0 = (pos < 1) ? pos : pos - 1; 385 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos; 386 if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2; 387 if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0; 388 s0 = x->data[x0]; 389 s1 = x->data[pos]; 390 s2 = x->data[x2]; 391 return pos + 0.5 * (s0 - s2 ) / (s0 - 2.* s1 + s2); 392 } 393 382 394 uint_t fvec_peakpick(fvec_t * onset, uint_t pos) { 383 395 uint_t tmp=0; -
src/mathutils.h
r002563f r9499eefb 236 236 smpl_t fvec_quadint (fvec_t * x, uint_t pos); 237 237 238 /** finds exact peak index by quadratic interpolation 239 240 See [Quadratic Interpolation of Spectral 241 Peaks](https://ccrma.stanford.edu/~jos/sasp/Quadratic_Peak_Interpolation.html), 242 by Julius O. Smith III 243 244 \f$ p_{frac} = \frac{1}{2} \frac {x[p-1] - x[p+1]} {x[p-1] - 2 x[p] + x[p+1]} \in [ -.5, .5] \f$ 245 246 \param x vector to get the interpolated peak position from 247 \param p index of the peak in vector `x` 248 \return \f$ p + p_{frac} \f$ exact peak position of interpolated maximum or minimum 249 250 */ 251 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t p); 252 238 253 /** Quadratic interpolation using Lagrange polynomial. 239 254
Note: See TracChangeset
for help on using the changeset viewer.