source: tests/src/spectral/test-tss.c @ f400ea1

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since f400ea1 was 9d6001cb, checked in by Paul Brossier <piem@piem.org>, 12 years ago

tests/src: fix memory leaks

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/* test sample for phase vocoder
2 *
3 * this program should start correctly using JACK_START_SERVER=true and
4 * reconstruct each audio input frame perfectly on the corresponding input with
5 * a delay equal to the window size, hop_s.
6 */
7
8#include <stdio.h>
9#define AUBIO_UNSTABLE 1
10#include <aubio.h>
11
12int main(){
13  int i;
14  uint_t win_s    = 1024; /* window size                       */
15  uint_t hop_s    = 256;  /* hop size                          */
16
17  /* allocate some memory */
18  fvec_t * in       = new_fvec (hop_s); /* input buffer       */
19  cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
20  cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
21  cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
22  fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
23  fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
24  /* allocate phase vocoders and transient steady-state separation */
25  aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
26  aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
27  aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
28  aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
29
30  /* fill input with some data */
31  printf("initialised\n");
32
33  /* execute stft */
34  for (i = 0; i < 10; i++) {
35    aubio_pvoc_do (pv,in,fftgrain);
36    aubio_tss_do  (tss,fftgrain,ctrans,cstead);
37    aubio_pvoc_rdo(pvt,cstead,stead);
38    aubio_pvoc_rdo(pvs,ctrans,trans);
39  }
40
41  del_aubio_pvoc(pv);
42  del_aubio_pvoc(pvt);
43  del_aubio_pvoc(pvs);
44  del_aubio_tss(tss);
45
46  del_fvec(in);
47  del_cvec(fftgrain);
48  del_cvec(cstead);
49  del_cvec(ctrans);
50  del_fvec(stead);
51  del_fvec(trans);
52  aubio_cleanup();
53  printf("memory freed\n");
54  return 0;
55}
Note: See TracBrowser for help on using the repository browser.