Changeset fbd3de6


Ignore:
Timestamp:
Mar 16, 2006, 4:37:59 PM (18 years ago)
Author:
Paul Brossier <piem@altern.org>
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:
f8a38c5
Parents:
8595fe3
Message:

use real fft for fcomb, severe tuning, complete del_, samplerate support
use real fft for fcomb, severe tuning, complete del_, samplerate support

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/pitchfcomb.c

    r8595fe3 rfbd3de6  
    3131#include "sample.h"
    3232#include "mathutils.h"
    33 #include "phasevoc.h"
     33#include "fft.h"
    3434#include "pitchfcomb.h"
    3535
     
    4343struct _aubio_pitchfcomb_t {
    4444        uint_t fftSize;
     45        uint_t stepSize;
    4546        uint_t rate;
     47        fvec_t * winput;
     48        fvec_t * win;
    4649        cvec_t * fftOut;
    4750        fvec_t * fftLastPhase;
    48         aubio_pvoc_t * pvoc;
     51        aubio_mfft_t * fft;
     52        //aubio_pvoc_t * pvoc;
    4953};
    5054
    51 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t size, uint_t samplerate)
     55aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t samplerate)
    5256{
    5357  aubio_pitchfcomb_t * p = AUBIO_NEW(aubio_pitchfcomb_t);
    54   uint_t overlap_rate = 4;
    5558  p->rate         = samplerate;
    56   p->fftSize      = size;
    57   p->fftOut       = new_cvec(size,1);
    58   p->fftLastPhase = new_fvec(size,1);
    59   p->pvoc = new_aubio_pvoc(size, size/overlap_rate, 1);
     59  p->fftSize      = bufsize;
     60  p->stepSize     = hopsize;
     61  p->winput       = new_fvec(bufsize,1);
     62  p->fftOut       = new_cvec(bufsize,1);
     63  p->fftLastPhase = new_fvec(bufsize,1);
     64  p->fft = new_aubio_mfft(bufsize, 1);
     65  p->win = new_fvec(bufsize,1);
     66  aubio_window(p->win->data[0], bufsize, aubio_win_hanning);
    6067  return p;
    6168}
     
    6471smpl_t aubio_pitchfcomb_detect (aubio_pitchfcomb_t * p, fvec_t * input)
    6572{
    66   uint_t k, l, maxharm = 0, stepSize = input->length;
     73  uint_t k, l, maxharm = 0;
    6774  smpl_t freqPerBin = p->rate/(smpl_t)p->fftSize,
    68     phaseDifference = TWO_PI*(smpl_t)stepSize/(smpl_t)p->fftSize;
     75    phaseDifference = TWO_PI*(smpl_t)p->stepSize/(smpl_t)p->fftSize;
    6976  aubio_fpeak_t peaks[MAX_PEAKS];
    7077
     
    7481  }
    7582
    76   aubio_pvoc_do (p->pvoc, input, p->fftOut);
     83  for (k=0; k < input->length; k++){
     84          p->winput->data[0][k] = p->win->data[0][k] * input->data[0][k];
     85  }
     86  aubio_mfft_do(p->fft,input,p->fftOut);
    7787
    78   for (k=0; k<=p->fftSize; k++) {
    79     //long qpd;
     88  for (k=0; k<=p->fftSize/2; k++) {
    8089    smpl_t
    8190      magnitude = 20.*LOG10(2.*p->fftOut->norm[0][k]/(smpl_t)p->fftSize),
     
    91100
    92101    /* map delta phase into +/- Pi interval */
    93     tmp = aubio_unwrap2pi(tmp);
     102    tmp = aubio_unwrap2pi(tmp) + PI;
    94103
    95104    /* get deviation from bin frequency from the +/- Pi interval */
    96     tmp = p->fftSize/input->length*tmp/(TWO_PI);
     105    tmp = p->stepSize/(smpl_t)p->fftSize*tmp/(TWO_PI);
    97106
    98107    /* compute the k-th partials' true frequency */
    99108    freq = (smpl_t)k*freqPerBin + tmp*freqPerBin;
    100109
    101     if (freq > 0.0 && magnitude > peaks[0].db && magnitude < 0) {
     110    if (freq > 0.0 && magnitude > peaks[0].db) { // && magnitude < 0) {
    102111      memmove(peaks+1, peaks, sizeof(aubio_fpeak_t)*(MAX_PEAKS-1));
    103112      peaks[0].freq = freq;
     
    129138  del_cvec(p->fftOut);
    130139  del_fvec(p->fftLastPhase);
    131   del_aubio_pvoc(p->pvoc);
     140  del_aubio_mfft(p->fft);
    132141  AUBIO_FREE(p);
    133142}
  • src/pitchfcomb.h

    r8595fe3 rfbd3de6  
    2828
    2929smpl_t aubio_pitchfcomb_detect (aubio_pitchfcomb_t *p, fvec_t * input);
    30 aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t size, uint_t samplerate);
     30aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t samplerate);
    3131void del_aubio_pitchfcomb (aubio_pitchfcomb_t *p);
    3232
Note: See TracChangeset for help on using the changeset viewer.