Changeset 8a5148e


Ignore:
Timestamp:
Feb 22, 2014, 8:00:02 PM (11 years ago)
Author:
Paul Brossier <piem@piem.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:
687eead
Parents:
4c0a1db
Message:

src/spectral/phasevoc.c: improve, accept that hop_s == buf_s

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/phasevoc.c

    r4c0a1db r8a5148e  
    3131  uint_t hop_s;       /** overlap step */
    3232  aubio_fft_t * fft;  /** fft object */
    33   fvec_t * synth;     /** cur output grain [win_s] */
    34   fvec_t * synthold;  /** last input frame [win_s-hop_s] */
    35   fvec_t * data;      /** current input grain [win_s] */
    36   fvec_t * dataold;   /** last input frame [win_s-hop_s] */
     33  fvec_t * data;      /** current input grain, [win_s] frames */
     34  fvec_t * dataold;   /** memory of past grain, [win_s-hop_s] frames */
     35  fvec_t * synth;     /** current output grain, [win_s] frames */
     36  fvec_t * synthold;  /** memory of past grain, [win_s-hop_s] frames */
    3737  fvec_t * w;         /** grain window [win_s] */
    3838};
     
    8181    AUBIO_ERR("got buffer_size %d, but can not be < 2\n", win_s);
    8282    goto beach;
    83   } else if (win_s < hop_s + 1) {
    84     AUBIO_ERR("hop size (%d) is larger than or equal to win size (%d)\n", win_s, hop_s);
     83  } else if (win_s < hop_s) {
     84    AUBIO_ERR("hop size (%d) is larger than win size (%d)\n", win_s, hop_s);
    8585    goto beach;
    8686  }
     
    9393
    9494  /* new input output */
    95   pv->dataold  = new_fvec  (win_s-hop_s);
    96   pv->synthold = new_fvec (win_s-hop_s);
     95  if (win_s > hop_s) {
     96    pv->dataold  = new_fvec  (win_s-hop_s);
     97    pv->synthold = new_fvec (win_s-hop_s);
     98  } else {
     99    pv->dataold  = new_fvec  (1);
     100    pv->synthold = new_fvec (1);
     101  }
    97102  pv->w        = new_aubio_window ("hanningz", win_s);
    98103
     
    141146                smpl_t * synthnew, uint_t win_s, uint_t hop_s)
    142147{
    143   uint_t i;
    144   smpl_t scale = 2 * hop_s / (win_s + .0);
    145   /* add new synth to old one and put result in synthnew */
     148  uint_t i, start;
     149  smpl_t scale = hop_s * 2. / win_s;
     150
     151  /* put new result in synthnew */
    146152  for (i = 0; i < hop_s; i++)
    147     synthnew[i] = synthold[i] + synth[i] * scale;
     153    synthnew[i] = synth[i] * scale;
     154  /* no overlap, nothing else to do */
     155  if (win_s <= hop_s) return;
     156
     157  /* add new synth to old one and */
     158  for (i = 0; i < hop_s; i++)
     159    synthnew[i] += synthold[i];
     160
    148161  /* shift synthold */
    149   for (i = 0; i < win_s - 2 * hop_s; i++)
    150     synthold[i] = synthold[i + hop_s];
     162  for (i = hop_s; i < win_s - hop_s; i++)
     163    synthold[i - hop_s] = synthold[i];
     164
     165  /* more than 50% overlap, overlap anyway */
     166  if (win_s < 2 * hop_s) start = 0;
     167  /* less than 50% overlap, reset latest grain trail */
     168  else start = win_s - hop_s - hop_s;
    151169  /* erase last frame in synthold */
    152   for (i = win_s - hop_s; i < win_s; i++)
    153     synthold[i - hop_s] = 0.;
     170  for (i = start; i < win_s - hop_s; i++)
     171    synthold[i] = 0.;
     172
    154173  /* additive synth */
    155174  for (i = 0; i < win_s - hop_s; i++)
Note: See TracChangeset for help on using the changeset viewer.