summaryrefslogtreecommitdiff
path: root/tests/src/spectral/test-tss.c
blob: 0e18b200aa1021f7d47ea5af5dc8069340d61330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <aubio.h>

int main (void)
{
  uint_t n = 10; // compute n times
  uint_t win_s = 1024; // window size
  uint_t hop_s = 256;  // hop size

  // create some vectors
  fvec_t * in       = new_fvec (hop_s); // input buffer
  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
  cvec_t * cstead   = new_cvec (win_s); // fft norm and phase
  cvec_t * ctrans   = new_cvec (win_s); // fft norm and phase
  fvec_t * stead    = new_fvec (hop_s); // output buffer
  fvec_t * trans    = new_fvec (hop_s); // output buffer

  // create phase vocoder for analysis of input signal 
  aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
  // create transient/steady-state separation object
  aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
  // create phase vocoder objects for synthesis of output signals
  aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
  aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);

  /* execute stft */
  while ( n-- ) {
    // fftgrain = pv(in)
    aubio_pvoc_do (pv, in, fftgrain);
    // ctrans, cstead = tss (fftgrain)
    aubio_tss_do (tss, fftgrain, ctrans, cstead);
    // stead = pvt_inverse (cstead)
    // trans = pvt_inverse (ctrans)
    aubio_pvoc_rdo (pvt, cstead, stead);
    aubio_pvoc_rdo (pvs, ctrans, trans);
  }

  del_aubio_pvoc(pv);
  del_aubio_pvoc(pvt);
  del_aubio_pvoc(pvs);
  del_aubio_tss(tss);

  del_fvec(in);
  del_cvec(fftgrain);
  del_cvec(cstead);
  del_cvec(ctrans);
  del_fvec(stead);
  del_fvec(trans);

  aubio_cleanup();

  return 0;
}