Index: tests/src/effects/test-pitchshift.c
===================================================================
--- tests/src/effects/test-pitchshift.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
+++ tests/src/effects/test-pitchshift.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
@@ -0,0 +1,75 @@
+#define AUBIO_UNSTABLE 1
+#include <aubio.h>
+#include "utils_tests.h"
+
+int main (int argc, char **argv)
+{
+  sint_t err = 0;
+
+  if (argc < 4) {
+    err = 2;
+    PRINT_ERR("not enough arguments\n");
+    PRINT_MSG("usage: %s <input_path> <output_path> <transpose> [mode] [hop_size] [samplerate]\n", argv[0]);
+    PRINT_MSG(" with <transpose> a number of semi tones in the range [-24, 24]\n");
+    PRINT_MSG(" and [mode] in 'default', 'crispness:0', ..., 'crispness:6'\n");
+    return err;
+  }
+
+  uint_t samplerate = 0;
+  uint_t hop_size = 64;
+  smpl_t transpose = 0.;
+  uint_t n_frames = 0, read = 0;
+
+  char_t *source_path = argv[1];
+  char_t *sink_path = argv[2];
+  char_t *mode = "default";
+
+  transpose = atof(argv[3]);
+
+  if ( argc >= 5 ) mode = argv[4];
+  if ( argc >= 6 ) hop_size = atoi(argv[5]);
+  if ( argc >= 7 ) samplerate = atoi(argv[6]);
+  if ( argc >= 8 ) {
+    err = 2;
+    PRINT_ERR("too many arguments\n");
+    return err;
+  }
+
+  fvec_t *vec = new_fvec(hop_size);
+  fvec_t *out = new_fvec(hop_size);
+  if (!vec) { err = 1; goto beach_fvec; }
+
+  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
+  if (!i) { err = 1; goto beach_source; }
+
+  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
+
+  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
+  if (!o) { err = 1; goto beach_sink; }
+
+  aubio_pitchshift_t *ps = new_aubio_pitchshift(mode, transpose, hop_size, samplerate);
+  if (!ps) { err = 1; goto beach_pitchshift; }
+
+  do {
+    aubio_source_do(i, vec, &read);
+    //aubio_pitchshift_set_transpose(ps, tranpose);
+    aubio_pitchshift_do(ps, vec, out);
+    aubio_sink_do(o, out, read);
+    n_frames += read;
+  } while ( read == hop_size );
+
+  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
+      n_frames, samplerate, n_frames / hop_size,
+      source_path, sink_path);
+
+  del_aubio_pitchshift(ps);
+beach_pitchshift:
+  del_aubio_sink(o);
+beach_sink:
+  del_aubio_source(i);
+beach_source:
+  del_fvec(vec);
+  del_fvec(out);
+beach_fvec:
+  return err;
+}
Index: tests/src/effects/test-timestretch.c
===================================================================
--- tests/src/effects/test-timestretch.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
+++ tests/src/effects/test-timestretch.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
@@ -0,0 +1,100 @@
+#define AUBIO_UNSTABLE 1
+#include <aubio.h>
+#include "utils_tests.h"
+
+int main (int argc, char **argv)
+{
+  sint_t err = 0;
+
+  if (argc < 4) {
+    err = 2;
+    PRINT_ERR("not enough arguments\n");
+    PRINT_MSG("usage: %s <input_path> <output_path> <stretch> [transpose] [mode] [hop_size] [samplerate]\n", argv[0]);
+    PRINT_MSG(" with <stretch> a time stretching ratio in the range [0.025, 10.]\n");
+    PRINT_MSG("      [transpose] a number of semi tones in the range [-24, 24]\n");
+    PRINT_MSG("  and [mode] in 'default', 'crispness:0', ..., 'crispness:6'\n");
+    return err;
+  }
+
+  uint_t samplerate = 0;
+  uint_t hop_size = 64;
+  smpl_t transpose = 0.;
+  smpl_t stretch = 1.;
+  uint_t n_frames = 0, read = 0;
+  uint_t eof = 0, source_read = 0;
+
+  char_t *source_path = argv[1];
+  char_t *sink_path = argv[2];
+  char_t *mode = "default";
+
+  stretch = atof(argv[3]);
+
+  if ( argc >= 5 ) transpose = atof(argv[4]);
+  if ( argc >= 6 ) mode = argv[5];
+  if ( argc >= 7 ) hop_size = atoi(argv[6]);
+  if ( argc >= 8 ) samplerate = atoi(argv[7]);
+  if ( argc >= 9 ) {
+    err = 2;
+    PRINT_ERR("too many arguments\n");
+    return err;
+  }
+
+  uint_t source_hopsize = 2048;
+  aubio_source_t *s = new_aubio_source(source_path, samplerate, source_hopsize);
+  if (!s) { err = 1; goto beach_source; }
+  if (samplerate == 0) samplerate = aubio_source_get_samplerate(s);
+
+  fvec_t *in = new_fvec(source_hopsize);
+  fvec_t *out = new_fvec(hop_size);
+  if (!out) { err = 1; goto beach_fvec; }
+
+  aubio_timestretch_t *ps = new_aubio_timestretch(mode, stretch, hop_size,
+      samplerate);
+  if (!ps) { err = 1; goto beach_timestretch; }
+  //if (samplerate == 0 ) samplerate = aubio_timestretch_get_samplerate(ps);
+
+  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
+  if (!o) { err = 1; goto beach_sink; }
+
+  if (transpose != 0) aubio_timestretch_set_transpose(ps, transpose);
+
+  do {
+    //aubio_timestretch_set_stretch(ps, stretch);
+    //aubio_timestretch_set_transpose(ps, transpose);
+
+    while (aubio_timestretch_get_available(ps) < (sint_t)hop_size && !eof) {
+      aubio_source_do(s, in, &source_read);
+      aubio_timestretch_push(ps, in, source_read);
+      if (source_read < in->length) eof = 1;
+    }
+#if 0
+    if (n_frames == hop_size * 200) {
+      PRINT_MSG("sampler: setting stretch gave %d\n",
+          aubio_timestretch_set_stretch(ps, 2.) );
+      PRINT_MSG("sampler: getting stretch gave %f\n",
+          aubio_timestretch_get_stretch(ps) );
+      PRINT_MSG("sampler: setting transpose gave %d\n",
+          aubio_timestretch_set_transpose(ps, 12.) );
+      PRINT_MSG("sampler: getting transpose gave %f\n",
+          aubio_timestretch_get_transpose(ps) );
+    }
+#endif
+    aubio_timestretch_do(ps, out, &read);
+    aubio_sink_do(o, out, read);
+    n_frames += read;
+  } while ( read == hop_size );
+
+  PRINT_MSG("wrote %d frames at %dHz (%d blocks) from %s written to %s\n",
+      n_frames, samplerate, n_frames / hop_size,
+      source_path, sink_path);
+
+  del_aubio_sink(o);
+beach_sink:
+  del_aubio_timestretch(ps);
+beach_timestretch:
+  del_fvec(out);
+beach_fvec:
+  del_aubio_source(s);
+beach_source:
+  return err;
+}
Index: tests/src/synth/test-sampler.c
===================================================================
--- tests/src/synth/test-sampler.c	(revision fead41ac21ffd37dd9eac4f5f4e1a301f9d4d1e1)
+++ tests/src/synth/test-sampler.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
@@ -1,4 +1,13 @@
 #include <aubio.h>
 #include "utils_tests.h"
+
+int time_was_reached (smpl_t time_s, uint_t n_frames, uint_t hop_size, uint_t samplerate) {
+    if ((n_frames / hop_size) == (uint_t)(time_s * samplerate) / hop_size) {
+      PRINT_MSG("reached %.2f sec at %d samples\n", time_s, n_frames);
+      return 1;
+    } else {
+      return 0;
+    }
+}
 
 int main (int argc, char **argv)
@@ -6,54 +15,114 @@
   sint_t err = 0;
 
-  if (argc < 4) {
+  if (argc < 2) {
     err = 2;
     PRINT_ERR("not enough arguments\n");
-    PRINT_MSG("usage: %s <input_path> <output_path> <sample_path> [samplerate]\n", argv[0]);
+    PRINT_MSG("usage: %s <sample_path> [samplerate] [blocksize] [output_path]\n", argv[0]);
     return err;
   }
 
-  uint_t samplerate = 0; // default is the samplerate of input_path
-  uint_t hop_size = 256;
-  uint_t n_frames = 0, read = 0;
+  uint_t samplerate = 44100; // default is 44100
+  uint_t hop_size = 64; //256;
+  uint_t n_frames = 0, frames_played = 0;
+  uint_t read = 0;
+  char_t *sink_path = NULL;
+  aubio_sink_t *sink = NULL;
 
-  char_t *source_path = argv[1];
-  char_t *sink_path = argv[2];
-  char_t *sample_path = argv[3];
-  if ( argc == 5 ) samplerate = atoi(argv[4]);
+  char_t *sample_path = argv[1];
+  if ( argc > 2 ) samplerate = atoi(argv[2]);
+  if ( argc > 3 ) hop_size = atoi(argv[3]);
+  if ( argc > 4 ) sink_path = argv[4];
 
   fvec_t *vec = new_fvec(hop_size);
-  aubio_source_t *source = new_aubio_source(source_path, samplerate, hop_size);
-  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source);
-  aubio_sink_t *sink = new_aubio_sink(sink_path, samplerate);
 
-  aubio_sampler_t * sampler = new_aubio_sampler (samplerate, hop_size);
+  aubio_sampler_t * sampler = new_aubio_sampler (hop_size, samplerate);
+  if (!vec) goto beach;
+  if (!sampler) goto beach_sampler;
+  // load source file
+  aubio_sampler_load (sampler, sample_path);
+  // load source file (asynchronously)
+  //aubio_sampler_queue (sampler, sample_path);
+  samplerate = aubio_sampler_get_samplerate (sampler);
+  if (samplerate == 0) {
+    PRINT_ERR("starting with samplerate = 0\n");
+    //goto beach_sink;
+  }
 
-  aubio_sampler_load (sampler, sample_path);
+  if (sink_path) {
+    sink = new_aubio_sink(sink_path, samplerate);
+    if (!sink) goto beach_sink;
+  }
+
+  smpl_t sample_duration = 2.953;
+  uint_t sample_repeat = 10;
+  smpl_t t1 = 1.,
+         t2 = t1 + sample_duration * sample_repeat - .1,
+         t3 = t2 - sample_duration + .1,
+         t4 = t3 + sample_duration + .1,
+         t5 = t4 + sample_duration + .1,
+         total_duration = t5 + sample_duration + .1;
+
+  //aubio_sampler_set_transpose(sampler, 0.);
+  //aubio_sampler_set_stretch(sampler, .8);
 
   do {
-    aubio_source_do(source, vec, &read);
-    if (n_frames / hop_size == 10) {
+    if (time_was_reached(t1, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test one shot play of loaded sample\n");
+      aubio_sampler_set_loop( sampler, 1);
       aubio_sampler_play ( sampler );
+    } else if (time_was_reached(t2, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test queueing while playing after eof was reached\n");
+      //aubio_sampler_queue (sampler, sample_path);
+      //aubio_sampler_play (sampler);
+      aubio_sampler_set_loop( sampler, 0);
+#if 0
+    } else if (time_was_reached(t3, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test queueing twice cancels the first one\n");
+      aubio_sampler_queue (sampler, sample_path);
+      aubio_sampler_queue (sampler, sample_path);
+      aubio_sampler_play (sampler);
+    } else if (time_was_reached(t4, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test queueing a corrupt file\n");
+      aubio_sampler_queue (sampler, "/dev/null");
+      aubio_sampler_play (sampler);
+    } else if (time_was_reached(t5, n_frames, hop_size, samplerate)) {
+      aubio_sampler_stop ( sampler );
+      PRINT_MSG("`-test queueing a correct file after a corrupt one\n");
+      uint_t i;
+      for (i = 0; i < 4; i++)
+        aubio_sampler_queue (sampler, "/dev/null");
+      aubio_sampler_queue (sampler, "/dev/null1");
+      aubio_sampler_queue (sampler, "/dev/null2");
+      aubio_sampler_queue (sampler, sample_path);
+      aubio_sampler_play (sampler);
+#endif
     }
+    /*
     if (n_frames / hop_size == 40) {
-      aubio_sampler_play ( sampler );
+      aubio_sampler_queue (sampler, sample_path);
+      aubio_sampler_queue (sampler, sample_path);
+      aubio_sampler_seek ( sampler, 0);
     }
     if (n_frames / hop_size == 70) {
-      aubio_sampler_play ( sampler );
+      aubio_sampler_seek ( sampler, 0);
     }
-    if (n_frames > 10.0 * samplerate) {
-      aubio_sampler_stop ( sampler );
-    }
-    aubio_sampler_do (sampler, vec, vec);
-    aubio_sink_do(sink, vec, read);
-    n_frames += read;
-  } while ( read == hop_size );
+    */
+    aubio_sampler_do (sampler, vec, &read);
+    if (sink) aubio_sink_do(sink, vec, hop_size);
+    n_frames += hop_size;
+    frames_played += read;
+  //} while ( read == hop_size );
+    // last for 40 seconds
+  } while ( n_frames <= total_duration * samplerate );
+  PRINT_MSG("reached %.2f sec at %d samples, sampler played %d frames\n",
+      total_duration, n_frames, frames_played);
 
+  if (sink) del_aubio_sink(sink);
+beach_sink:
   del_aubio_sampler(sampler);
-  del_aubio_source(source);
-  del_aubio_sink(sink);
+beach_sampler:
   del_fvec(vec);
+beach:
   aubio_cleanup();
-
   return 0;
 }
Index: tests/src/synth/test-sampler_table.c
===================================================================
--- tests/src/synth/test-sampler_table.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
+++ tests/src/synth/test-sampler_table.c	(revision 41b985f1e3468fe8547f44c2ae6b38f2a437a3f3)
@@ -0,0 +1,99 @@
+#include <aubio.h>
+#include "utils_tests.h"
+
+int time_was_reached (smpl_t time_s, uint_t n_frames, uint_t hop_size, uint_t samplerate) {
+    if ((n_frames / hop_size) == (uint_t)(time_s * samplerate) / hop_size) {
+      PRINT_MSG("reached %.2f sec at %d samples\n", time_s, n_frames);
+      return 1;
+    } else {
+      return 0;
+    }
+}
+
+int main (int argc, char **argv)
+{
+  sint_t err = 0;
+
+  if (argc < 1) {
+    err = 2;
+    PRINT_ERR("not enough arguments\n");
+    PRINT_MSG("usage: %s [samplerate] [blocksize] [output_path]\n", argv[0]);
+    return err;
+  }
+
+  uint_t samplerate = 44100;
+  uint_t hop_size = 64; //256;
+  uint_t n_frames = 0, frames_played = 0;
+  uint_t read = 0;
+  char_t *sink_path = NULL;
+  aubio_sink_t *sink = NULL;
+
+  if ( argc > 1 ) samplerate = atoi(argv[1]);
+  if ( argc > 2 ) hop_size = atoi(argv[2]);
+  if ( argc > 3 ) sink_path = argv[3];
+
+  fvec_t *vec = new_fvec(hop_size);
+
+  aubio_sampler_t * sampler = new_aubio_sampler (hop_size, samplerate);
+  if (!vec) goto beach;
+  if (!sampler) goto beach_sampler;
+  // load source file
+  //aubio_sampler_load (sampler, sample_path);
+  // load source file (asynchronously)
+  //aubio_sampler_queue (sampler, sample_path);
+  samplerate = aubio_sampler_get_samplerate (sampler);
+  if (samplerate == 0) {
+    PRINT_ERR("starting with samplerate = 0\n");
+    //goto beach_sink;
+  }
+
+  //fvec_t *table = new_fvec(1234560);
+  fvec_t *table = new_fvec(123456);
+
+  aubio_sampler_set_table(sampler, table);
+
+  if (sink_path) {
+    sink = new_aubio_sink(sink_path, samplerate);
+    if (!sink) goto beach_sink;
+  }
+
+  smpl_t sample_duration = table->length/(smpl_t) samplerate;
+  uint_t sample_repeat = 10;
+  smpl_t t1 = 1.,
+         t2 = t1 + sample_duration * sample_repeat - .1,
+         t3 = t2 - sample_duration + .1,
+         t4 = t3 + sample_duration + .1,
+         t5 = t4 + sample_duration + .1,
+         total_duration = t5 + sample_duration + .1;
+
+  //aubio_sampler_set_transpose(sampler, 0.);
+  //aubio_sampler_set_stretch(sampler, .8);
+
+  do {
+    if (time_was_reached(t1, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test one shot play of loaded sample\n");
+      aubio_sampler_set_loop( sampler, 1);
+      aubio_sampler_play ( sampler );
+    } else if (time_was_reached(t2, n_frames, hop_size, samplerate)) {
+      PRINT_MSG("`-test queueing while playing after eof was reached\n");
+      //aubio_sampler_queue (sampler, sample_path);
+      //aubio_sampler_play (sampler);
+      aubio_sampler_set_loop( sampler, 0);
+    }
+    aubio_sampler_do (sampler, vec, &read);
+    if (sink) aubio_sink_do(sink, vec, hop_size);
+    n_frames += hop_size;
+    frames_played += read;
+  } while ( n_frames <= total_duration * samplerate );
+  PRINT_MSG("reached %.2f sec at %d samples, sampler played %d frames\n",
+      total_duration, n_frames, frames_played);
+
+  if (sink) del_aubio_sink(sink);
+beach_sink:
+  del_aubio_sampler(sampler);
+beach_sampler:
+  del_fvec(vec);
+beach:
+  aubio_cleanup();
+  return 0;
+}
