Changeset d94f98b for src


Ignore:
Timestamp:
Mar 21, 2006, 11:26:28 PM (19 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:
e4f7779
Parents:
9771488
Message:

fix mcomb: comput instfreq, use pow(mag,0.25) for comb summation
fix mcomb: comput instfreq, use pow(mag,0.25) for comb summation

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/pitchmcomb.c

    r9771488 rd94f98b  
    6464  fvec_t * scratch;                        /**< vec to store modified mag            */
    6565  fvec_t * scratch2;                       /**< vec to compute moving median         */
     66  fvec_t * theta;                         /**< vec to store phase                     */
     67  smpl_t phasediff;
     68  smpl_t phasefreq;
    6669  /** threshfn: name or handle of fn for computing adaptive threshold [median] */
    6770  /** aubio_thresholdfn_t thresholdfn; */
     
    8891smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain) {
    8992  uint_t i=0,j;
     93  smpl_t instfreq;
    9094  fvec_t * newmag = (fvec_t *)p->newmag;
    9195  //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta;
     
    99103    aubio_pitchmcomb_combdet(p,newmag);
    100104    //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
    101     // print picked candidate
    102     //AUBIO_DBG("%f\n",p->candidates[p->goodcandidate]->ebin);
    103     //AUBIO_DBG("%f\n",p->candidates[p->goodcandidate]->ebin);
    104     return p->candidates[p->goodcandidate]->ebin;
     105    //return p->candidates[p->goodcandidate]->ebin;
     106  j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5);
     107  instfreq  = aubio_unwrap2pi(fftgrain->phas[0][j]
     108                  - p->theta->data[0][j] - j*p->phasediff);
     109  instfreq *= p->phasefreq;
     110  /* store phase for next run */
     111  for (j=0; j< p->theta->length; j++) {
     112    p->theta->data[i][j]=fftgrain->phas[i][j];
     113  }
     114  return FLOOR(p->candidates[p->goodcandidate]->ebin+.5) + instfreq;
    105115  /*} else {
    106116    return -1.;
     
    193203  /* get the biggest peak in the spectrum */
    194204  root_peak = aubio_pitchmcomb_get_root_peak(peaks,count);
    195   if (peaks[root_peak].ebin > aubio_miditofreq(80.)/p->tau) N = 3;
    196   if (peaks[root_peak].ebin > aubio_miditofreq(85.)/p->tau) N = 2;
    197   if (peaks[root_peak].ebin > aubio_miditofreq(90.)/p->tau) N = 1;
    198205  /* now calculate the energy of each of the 5 combs */
    199206  for (l=0;l<M;l++) {
     
    227234        candidate[l]->ecomb[k]=peaks[position].ebin;
    228235        candidate[l]->ene += /* ecomb rounded to nearest int */
    229           SQR(newmag->data[0][(uint_t)FLOOR(candidate[l]->ecomb[k]-.5)]);
     236          POW(newmag->data[0][(uint_t)FLOOR(candidate[l]->ecomb[k]+.5)],0.25);
    230237        candidate[l]->len += 1./curlen;
    231238      } else
     
    233240    }
    234241    /* punishment */
    235     if (candidate[l]->len<0.6)
    236       candidate[l]->ene=0.;
    237     /* remember best candidate energy */
    238     if (tmpene <= candidate[l]->ene) {
     242    /*if (candidate[l]->len<0.6)
     243      candidate[l]->ene=0.; */
     244    /* remember best candidate energy (in polyphonic, could check for
     245     * tmpene*1.1 < candidate->ene to reduce jumps towards low frequencies) */
     246    if (tmpene < candidate[l]->ene) {
    239247      tmpl = l;
    240248      tmpene = candidate[l]->ene;
     
    311319}
    312320
    313 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t size, uint_t channels, uint_t samplerate) {
     321aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) {
    314322  aubio_pitchmcomb_t * p = AUBIO_NEW(aubio_pitchmcomb_t);
    315323  /** \bug should check if size / 8 > post+pre+1 */
     
    323331  p->win_post         = 8;
    324332  p->win_pre          = 7;
    325   p->tau              = samplerate/size;
     333  p->tau              = samplerate/bufsize;
    326334  p->alpha            = 9.;
    327335  p->goodcandidate    = 0;
    328   spec_size = size/p->spec_partition;
     336  p->phasefreq        = bufsize/hopsize/TWO_PI;
     337  p->phasediff        = TWO_PI*hopsize/bufsize;
     338  spec_size = bufsize/p->spec_partition;
    329339  //p->pickerfn = quadpick;
    330340  //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348);
     
    333343  /* array for median */
    334344  p->scratch    = new_fvec(spec_size,channels);
     345  /* array for phase */
     346  p->theta      = new_fvec(spec_size,channels);
    335347  /* array for adaptative threshold */
    336348  p->scratch2   = new_fvec(p->win_post+p->win_pre+1,channels);
  • src/pitchmcomb.h

    r9771488 rd94f98b  
    3535smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain);
    3636uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands);
    37 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t size, uint_t channels, uint_t samplerate);
     37aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
    3838void del_aubio_pitchmcomb(aubio_pitchmcomb_t *p);
    3939
Note: See TracChangeset for help on using the changeset viewer.