Changeset e7d4aa0


Ignore:
Timestamp:
Dec 7, 2018, 1:28:56 AM (12 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/timestretch
Children:
9b0ffe3
Parents:
284fe8a
git-author:
Paul Brossier <piem@piem.org> (11/28/16 15:40:57)
git-committer:
Paul Brossier <piem@piem.org> (12/07/18 01:28:56)
Message:

tests/src/effects/test-timestretch.c: update to use new interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/effects/test-timestretch.c

    r284fe8a re7d4aa0  
    2222  smpl_t stretch = 1.;
    2323  uint_t n_frames = 0, read = 0;
     24  uint_t eof = 0, source_read = 0;
    2425
    2526  char_t *source_path = argv[1];
     
    3940  }
    4041
     42  uint_t source_hopsize = 2048;
     43  aubio_source_t *s = new_aubio_source(source_path, samplerate, source_hopsize);
     44  if (!s) { err = 1; goto beach_source; }
     45  if (samplerate == 0) samplerate = aubio_source_get_samplerate(s);
     46
     47  fvec_t *in = new_fvec(source_hopsize);
    4148  fvec_t *out = new_fvec(hop_size);
    4249  if (!out) { err = 1; goto beach_fvec; }
    4350
    44   aubio_timestretch_t *ps = new_aubio_timestretch(source_path, mode,
    45       stretch, hop_size, samplerate);
     51  aubio_timestretch_t *ps = new_aubio_timestretch(mode, stretch, hop_size,
     52      samplerate);
    4653  if (!ps) { err = 1; goto beach_timestretch; }
    47   if (samplerate == 0 ) samplerate = aubio_timestretch_get_samplerate(ps);
     54  //if (samplerate == 0 ) samplerate = aubio_timestretch_get_samplerate(ps);
    4855
    4956  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
     
    5259  if (transpose != 0) aubio_timestretch_set_transpose(ps, transpose);
    5360
     61  do {
     62    //aubio_timestretch_set_stretch(ps, stretch);
     63    //aubio_timestretch_set_transpose(ps, transpose);
     64
     65    while (aubio_timestretch_get_available(ps) < (sint_t)hop_size && !eof) {
     66      aubio_source_do(s, in, &source_read);
     67      aubio_timestretch_push(ps, in, source_read);
     68      if (source_read < in->length) eof = 1;
     69    }
    5470#if 0
    55   do {
    56     if (aubio_timestretch_get_opened(ps) == 0)
    57       PRINT_MSG("not opened!\n");
    58     aubio_timestretch_get_opened(ps);
    59     aubio_timestretch_set_stretch(ps, stretch);
    60     aubio_timestretch_set_transpose(ps, transpose);
     71    if (n_frames == hop_size * 200) {
     72      PRINT_MSG("sampler: setting stretch gave %d\n",
     73          aubio_timestretch_set_stretch(ps, 2.) );
     74      PRINT_MSG("sampler: getting stretch gave %f\n",
     75          aubio_timestretch_get_stretch(ps) );
     76      PRINT_MSG("sampler: setting transpose gave %d\n",
     77          aubio_timestretch_set_transpose(ps, 12.) );
     78      PRINT_MSG("sampler: getting transpose gave %f\n",
     79          aubio_timestretch_get_transpose(ps) );
     80    }
     81#endif
    6182    aubio_timestretch_do(ps, out, &read);
    62     if (samplerate == 0) {
    63       PRINT_MSG("setting samplerate now to %d\n", aubio_timestretch_get_samplerate(ps));
    64       samplerate = aubio_timestretch_get_samplerate(ps);
    65       aubio_sink_preset_samplerate(o, samplerate);
    66       aubio_sink_preset_channels(o, 1);
    67     }
    6883    aubio_sink_do(o, out, read);
    6984    n_frames += read;
    7085  } while ( read == hop_size );
    71 #else
    72 
    73   aubio_timestretch_queue(ps, source_path, samplerate);
    74 
    75   do {
    76     aubio_timestretch_get_opened(ps);
    77     aubio_timestretch_set_stretch(ps, stretch);
    78     aubio_timestretch_set_transpose(ps, transpose);
    79     aubio_timestretch_do(ps, out, &read);
    80     if (n_frames == 34999 * hop_size) {
    81       PRINT_MSG("instant queuing?\n");
    82       aubio_timestretch_queue(ps, source_path, samplerate);
    83     }
    84     if (n_frames == 64999 * hop_size) {
    85       PRINT_MSG("instant queuing 2\n");
    86       aubio_timestretch_queue(ps, "/dev/null", samplerate);
    87     }
    88     if (n_frames == 54999 * hop_size) {
    89       PRINT_MSG("instant queuing?\n");
    90       aubio_timestretch_queue(ps, source_path, samplerate);
    91     }
    92     if (n_frames == 74999 * hop_size) {
    93       PRINT_MSG("instant queuing?\n");
    94       aubio_timestretch_queue(ps, source_path, samplerate);
    95     }
    96     aubio_sink_do(o, out, read);
    97   //} while ( read == hop_size );
    98     n_frames += hop_size;
    99   } while ( n_frames < 100000 * hop_size);
    100 #endif
    10186
    10287  PRINT_MSG("wrote %d frames at %dHz (%d blocks) from %s written to %s\n",
     
    11095  del_fvec(out);
    11196beach_fvec:
     97  del_aubio_source(s);
     98beach_source:
    11299  return err;
    113100}
Note: See TracChangeset for help on using the changeset viewer.