Changeset 9499eefb for src/mathutils.c


Ignore:
Timestamp:
Apr 8, 2013, 5:19:10 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
69d642a
Parents:
002563f
Message:

src/mathutils.{c,h}: add fvec_quadratic_peak_pos, a fixed replacement for fvec_quadint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r002563f r9499eefb  
    11/*
    2   Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
     2  Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
    33
    44  This file is part of aubio.
     
    380380}
    381381
     382smpl_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
    382394uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
    383395  uint_t tmp=0;
Note: See TracChangeset for help on using the changeset viewer.