Advertisement
Guest User

test-stretch.c

a guest
Mar 24th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.77 KB | None | 0 0
  1. #include "../llsm.h"
  2. #include "../external/libpyin/pyin.h"
  3. #include "verify-utils.h"
  4.  
  5. int main() {
  6.   int fs = 0;
  7.   int nbit = 0;
  8.   int nx = 0;
  9.   FP_TYPE* x = wavread("test/sample/yuri_orig.wav", & fs, & nbit, & nx);
  10.  
  11.   int nhop = 128;
  12.   int nfrm = 0;
  13.   pyin_config param = pyin_init(nhop);
  14.   param.fmin = 50.0;
  15.   param.fmax = 500.0;
  16.   param.trange = 24;
  17.   param.bias = 2;
  18.   param.nf = ceil(fs * 0.025);
  19.   FP_TYPE* f0 = pyin_analyze(param, x, nx, fs, & nfrm);
  20.  
  21.   llsm_aoptions* opt_a = llsm_create_aoptions();
  22.   opt_a -> thop = (FP_TYPE)nhop / fs;
  23.   llsm_soptions* opt_s = llsm_create_soptions(fs);
  24.   llsm_chunk* chunk = llsm_analyze(opt_a, x, nx, fs, f0, nfrm, NULL);
  25.   llsm_chunk_tolayer1(chunk, 2048);
  26.   llsm_chunk_phasepropagate(chunk, -1);
  27.  
  28.   int nfrm_new = nfrm * 2;
  29.   llsm_container* conf_new = llsm_copy_container(chunk -> conf);
  30.   llsm_container_attach(conf_new, LLSM_CONF_NFRM,
  31.     llsm_create_int(nfrm_new), llsm_delete_int, llsm_copy_int);
  32.   llsm_chunk* chunk_new = llsm_create_chunk(conf_new, 0);
  33.   llsm_delete_container(conf_new);
  34.  
  35.   for(int i = 0; i < nfrm_new; i ++) {
  36.     chunk_new -> frames[i] = llsm_copy_container(chunk -> frames[i / 2]);
  37.   }
  38.   llsm_chunk_tolayer0(chunk_new);
  39.   llsm_chunk_phasepropagate(chunk_new, 1);
  40.  
  41.   llsm_output* out = llsm_synthesize(opt_s, chunk_new);
  42.   wavwrite(out -> y_noise, out -> ny, opt_s -> fs, 24,
  43.     "test/test-stretch-noise.wav");
  44.   wavwrite(out -> y_sin  , out -> ny, opt_s -> fs, 24,
  45.     "test/test-stretch-sin.wav");
  46.   wavwrite(out -> y      , out -> ny, opt_s -> fs, 24,
  47.     "test/test-stretch.wav");
  48.   llsm_delete_output(out);
  49.  
  50.   llsm_delete_chunk(chunk);
  51.   llsm_delete_chunk(chunk_new);
  52.   llsm_delete_aoptions(opt_a);
  53.   llsm_delete_soptions(opt_s);
  54.   free(f0);
  55.   free(x);
  56.   return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement