Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../llsm.h"
- #include "../external/libpyin/pyin.h"
- #include "verify-utils.h"
- int main() {
- int fs = 0;
- int nbit = 0;
- int nx = 0;
- FP_TYPE* x = wavread("test/sample/yuri_orig.wav", & fs, & nbit, & nx);
- int nhop = 128;
- int nfrm = 0;
- pyin_config param = pyin_init(nhop);
- param.fmin = 50.0;
- param.fmax = 500.0;
- param.trange = 24;
- param.bias = 2;
- param.nf = ceil(fs * 0.025);
- FP_TYPE* f0 = pyin_analyze(param, x, nx, fs, & nfrm);
- llsm_aoptions* opt_a = llsm_create_aoptions();
- opt_a -> thop = (FP_TYPE)nhop / fs;
- llsm_soptions* opt_s = llsm_create_soptions(fs);
- llsm_chunk* chunk = llsm_analyze(opt_a, x, nx, fs, f0, nfrm, NULL);
- llsm_chunk_tolayer1(chunk, 2048);
- llsm_chunk_phasepropagate(chunk, -1);
- int nfrm_new = nfrm * 2;
- llsm_container* conf_new = llsm_copy_container(chunk -> conf);
- llsm_container_attach(conf_new, LLSM_CONF_NFRM,
- llsm_create_int(nfrm_new), llsm_delete_int, llsm_copy_int);
- llsm_chunk* chunk_new = llsm_create_chunk(conf_new, 0);
- llsm_delete_container(conf_new);
- for(int i = 0; i < nfrm_new; i ++) {
- chunk_new -> frames[i] = llsm_copy_container(chunk -> frames[i / 2]);
- }
- llsm_chunk_tolayer0(chunk_new);
- llsm_chunk_phasepropagate(chunk_new, 1);
- llsm_output* out = llsm_synthesize(opt_s, chunk_new);
- wavwrite(out -> y_noise, out -> ny, opt_s -> fs, 24,
- "test/test-stretch-noise.wav");
- wavwrite(out -> y_sin , out -> ny, opt_s -> fs, 24,
- "test/test-stretch-sin.wav");
- wavwrite(out -> y , out -> ny, opt_s -> fs, 24,
- "test/test-stretch.wav");
- llsm_delete_output(out);
- llsm_delete_chunk(chunk);
- llsm_delete_chunk(chunk_new);
- llsm_delete_aoptions(opt_a);
- llsm_delete_soptions(opt_s);
- free(f0);
- free(x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement