Changeset 08bd8e0 for tests/src/io


Ignore:
Timestamp:
Oct 15, 2013, 5:59:33 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
d770fd2
Parents:
3819aca
Message:

tests/src/io/test-source_seek.c: improve test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/io/test-source_seek.c

    r3819aca r08bd8e0  
    2323  uint_t hop_size = 256;
    2424  uint_t n_frames = 0, read = 0;
    25   uint_t old_n_frames;
     25  uint_t old_n_frames_1, old_n_frames_2, old_n_frames_3;
    2626  if ( argc == 3 ) samplerate = atoi(argv[2]);
    2727  if ( argc == 4 ) hop_size = atoi(argv[3]);
     
    4242  } while ( read == hop_size );
    4343
    44   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    45     n_frames / hop_size, source_path);
     44  PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n",
     45      n_frames * 1. / samplerate,
     46      n_frames, samplerate,
     47      n_frames / hop_size, source_path);
     48
     49  old_n_frames_1 = n_frames;
    4650
    4751  aubio_source_seek (s, 0);
    48 
    49   old_n_frames = n_frames;
    5052
    5153  n_frames = 0;
     
    5658  } while ( read == hop_size );
    5759
    58   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    59     n_frames / hop_size, source_path);
     60  PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n",
     61      n_frames * 1. / samplerate,
     62      n_frames, samplerate,
     63      n_frames / hop_size, source_path);
     64
     65  old_n_frames_2 = n_frames;
     66
     67  aubio_source_seek (s, n_frames / 2);
     68
     69  n_frames = 0;
     70  do {
     71    aubio_source_do(s, vec, &read);
     72    //fvec_print (vec);
     73    n_frames += read;
     74  } while ( read == hop_size );
     75
     76  PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n",
     77      n_frames * 1. / samplerate,
     78      n_frames, samplerate,
     79      n_frames / hop_size, source_path);
     80
     81  old_n_frames_3 = n_frames;
    6082
    6183  del_aubio_source (s);
     
    6385  del_fvec (vec);
    6486
    65   assert ( n_frames == old_n_frames );
     87  assert ( old_n_frames_2 == old_n_frames_1 );
     88  assert ( old_n_frames_3 == (uint_t)floor(old_n_frames_1 / 2. + .5) );
    6689  return err;
    6790}
Note: See TracChangeset for help on using the changeset viewer.