Index: examples/aubionotes.c
===================================================================
--- examples/aubionotes.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ examples/aubionotes.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -40,8 +40,4 @@
       aubio_pvoc_do (pv,ibuf, fftgrain);
       aubio_onsetdetection_do(o,fftgrain, onset);
-      if (usedoubled) {
-        aubio_onsetdetection_do(o2,fftgrain, onset2);
-        onset->data[0][0] *= onset2->data[0][0];
-      }
       isonset = aubio_peakpicker_do(parms, onset);
       
Index: examples/aubioonset.c
===================================================================
--- examples/aubioonset.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ examples/aubioonset.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -40,8 +40,4 @@
       aubio_pvoc_do (pv,ibuf, fftgrain);
       aubio_onsetdetection_do (o,fftgrain, onset);
-      if (usedoubled) {
-        aubio_onsetdetection_do (o2,fftgrain, onset2);
-        onset->data[0][0] *= onset2->data[0][0];
-      }
       isonset = aubio_peakpicker_do(parms, onset);
       if (isonset) {
Index: examples/utils.c
===================================================================
--- examples/utils.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ examples/utils.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -65,5 +65,4 @@
 fvec_t *woodblock;
 aubio_onsetdetection_t *o;
-aubio_onsetdetection_t *o2;
 fvec_t *onset;
 fvec_t *onset2;
@@ -75,6 +74,6 @@
 smpl_t pitch = 0.;
 aubio_pitchdetection_t *pitchdet;
-aubio_pitchdetection_type type_pitch = aubio_pitch_yinfft;      // aubio_pitch_mcomb
-aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;
+char_t * pitch_unit = "default";
+char_t * pitch_mode = "default";
 uint_t median = 6;
 
@@ -177,18 +176,5 @@
         break;
       case 'p':
-        if (strcmp (optarg, "mcomb") == 0)
-          type_pitch = aubio_pitch_mcomb;
-        else if (strcmp (optarg, "yinfft") == 0)
-          type_pitch = aubio_pitch_yin;
-        else if (strcmp (optarg, "yin") == 0)
-          type_pitch = aubio_pitch_yin;
-        else if (strcmp (optarg, "schmitt") == 0)
-          type_pitch = aubio_pitch_schmitt;
-        else if (strcmp (optarg, "fcomb") == 0)
-          type_pitch = aubio_pitch_fcomb;
-        else {
-          errmsg ("unknown pitch type.\n");
-          abort ();
-        }
+        pitch_mode = optarg;
         break;
       case 'a':
@@ -294,6 +280,6 @@
 
   if (usepitch) {
-    pitchdet = new_aubio_pitchdetection (buffer_size * 4,
-        overlap_size, channels, samplerate, type_pitch, mode_pitch);
+    pitchdet = new_aubio_pitchdetection (pitch_mode, buffer_size * 4,
+        overlap_size, channels, samplerate);
     aubio_pitchdetection_set_tolerance (pitchdet, 0.7);
     pitch_obuf = new_fvec (1, channels);
@@ -325,8 +311,4 @@
     }
     del_fvec (pitch_obuf);
-  }
-  if (usedoubled) {
-    del_aubio_onsetdetection (o2);
-    del_fvec (onset2);
   }
   del_aubio_onsetdetection (o);
Index: examples/utils.h
===================================================================
--- examples/utils.h	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ examples/utils.h	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -108,5 +108,4 @@
 extern smpl_t pitch;
 extern aubio_pitchdetection_t *pitchdet;
-extern aubio_pitchdetection_type mode;
 extern uint_t median;
 
Index: plugins/puredata/aubiopitch~.c
===================================================================
--- plugins/puredata/aubiopitch~.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ plugins/puredata/aubiopitch~.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -13,7 +13,4 @@
 
 char aubiopitch_version[] = "aubiopitch~ version 0.1";
-
-aubio_pitchdetection_type type_pitch = aubio_pitch_yinfft;
-aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;
 
 static t_class *aubiopitch_tilde_class;
@@ -79,21 +76,7 @@
 	x->hopsize   = x->bufsize / 2;
 
-        if (strcmp(s->s_name,"mcomb") == 0) 
-                type_pitch = aubio_pitch_mcomb;
-        else if (strcmp(s->s_name,"yinfft") == 0) 
-                type_pitch = aubio_pitch_yin;
-        else if (strcmp(s->s_name,"yin") == 0) 
-                type_pitch = aubio_pitch_yin;
-        else if (strcmp(s->s_name,"schmitt") == 0) 
-                type_pitch = aubio_pitch_schmitt;
-        else if (strcmp(s->s_name,"fcomb") == 0) 
-                type_pitch = aubio_pitch_fcomb;
-        else {
-                post("unknown pitch type, using default.\n");
-        }
-
 	//FIXME: get the real samplerate
-    	x->o = new_aubio_pitchdetection(x->bufsize, 
-                    x->hopsize, 1, 44100., type_pitch, mode_pitch);
+    x->o = new_aubio_pitchdetection(s->s_name, x->bufsize, 
+            x->hopsize, 1, 44100.);
 	aubio_pitchdetection_set_tolerance (x->o, 0.7);
 	x->vec = (fvec_t *)new_fvec(x->hopsize,1);
Index: python/aubio/aubioclass.py
===================================================================
--- python/aubio/aubioclass.py	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ python/aubio/aubioclass.py	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -125,9 +125,10 @@
 
 class pitchdetection:
-    def __init__(self,mode=aubio_pitch_mcomb,bufsize=2048,hopsize=1024,
-        channels=1,samplerate=44100.,omode=aubio_pitchm_freq,tolerance=0.1):
-        self.pitchp = new_aubio_pitchdetection(bufsize,hopsize,channels,
-                samplerate,mode,omode)
+    def __init__(self,mode="mcomb",bufsize=2048,hopsize=1024,
+        channels=1,samplerate=44100.,omode="freq",tolerance=0.1):
+        self.pitchp = new_aubio_pitchdetection(mode,bufsize,hopsize,channels,
+            samplerate)
         self.mypitch = fvec(1, channels)
+        aubio_pitchdetection_set_unit(self.pitchp,omode)
         aubio_pitchdetection_set_tolerance(self.pitchp,tolerance)
         #self.filt     = filter(srate,"adsgn")
Index: python/aubio/task/params.py
===================================================================
--- python/aubio/task/params.py	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ python/aubio/task/params.py	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -1,3 +1,2 @@
-from aubio.aubioclass import aubio_pitchm_freq
 
 class taskparams(object):
@@ -30,5 +29,5 @@
 		self.pitchdelay = -0.5
 		self.dcthreshold = -1.
-		self.omode = aubio_pitchm_freq
+		self.omode = "freq"
 		self.verbose   = False
 
Index: python/aubio/task/pitch.py
===================================================================
--- python/aubio/task/pitch.py	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ python/aubio/task/pitch.py	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -14,5 +14,5 @@
 		else:
 			tolerance = 0.
-		self.pitchdet	= pitchdetection(mode=get_pitch_mode(self.params.pitchmode),
+		self.pitchdet	= pitchdetection(mode=self.params.pitchmode,
 			bufsize=self.params.bufsize,
 			hopsize=self.params.hopsize,
Index: python/aubio/task/utils.py
===================================================================
--- python/aubio/task/utils.py	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ python/aubio/task/utils.py	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -26,21 +26,4 @@
 		 sys.exit(1)
 
-def get_pitch_mode(nvalue):
-	""" utility function to convert a string to aubio_pitchdetection_type """
-	if   nvalue == 'mcomb'  :
-		 return aubio_pitch_mcomb
-	elif nvalue == 'yin'    :
-		 return aubio_pitch_yin
-	elif nvalue == 'fcomb'  :
-		 return aubio_pitch_fcomb
-	elif nvalue == 'schmitt':
-		 return aubio_pitch_schmitt
-	elif nvalue == 'yinfft':
-		 return aubio_pitch_yinfft
-	else:
-		 import sys
-		 print "error: unknown pitch detection function selected"
-		 sys.exit(1)
-
 def check_onset_mode(option, opt, value, parser):
 	""" wrapper function to convert a list of modes to 
@@ -59,20 +42,2 @@
 		val.append(get_pitch_mode(nvalue))
 		setattr(parser.values, option.dest, val)
-
-def check_pitchm_mode(option, opt, value, parser):
-	""" utility function to convert a string to aubio_pitchdetection_mode """
-	nvalue = parser.rargs[0]
-	if   nvalue == 'freq'  :
-		 setattr(parser.values, option.dest, aubio_pitchm_freq)
-	elif nvalue == 'midi'  :
-		 setattr(parser.values, option.dest, aubio_pitchm_midi)
-	elif nvalue == 'cent'  :
-		 setattr(parser.values, option.dest, aubio_pitchm_cent)
-	elif nvalue == 'bin'   :
-		 setattr(parser.values, option.dest, aubio_pitchm_bin)
-	else:
-		 import sys
-		 print "error: unknown pitch detection output selected"
-		 sys.exit(1)
-
-
Index: python/aubiopitch
===================================================================
--- python/aubiopitch	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ python/aubiopitch	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -18,10 +18,9 @@
       help="input sound file")
   parser.add_option("-m","--mode", 
-      action="store", dest="mode", default='mcomb',
+      action="store", dest="mode", default='yinfft',
       help="pitch detection mode [default=mcomb] \
       mcomb|yin|fcomb|schmitt")
-  parser.add_option("-u","--units", action="callback", 
-      callback=check_pitchm_mode, dest="omode",
-      default=aubio_pitchm_freq,
+  parser.add_option("-u","--units",
+      action="store", dest="omode", default="freq",
       help="output pitch in units [default=Hz] \
       freq|midi|cent|bin")
@@ -78,8 +77,8 @@
   (options, args) = parser.parse_args()
   if not options.bufsize:
-    if options.mode == aubio_pitch_yin:     options.bufsize = 1024
-    if options.mode == aubio_pitch_schmitt: options.bufsize = 2048
-    if options.mode == aubio_pitch_mcomb:   options.bufsize = 4096
-    if options.mode == aubio_pitch_fcomb:   options.bufsize = 4096 
+    if options.mode == "yin":     options.bufsize = 1024
+    if options.mode == "schmitt": options.bufsize = 2048
+    if options.mode == "mcomb":   options.bufsize = 4096
+    if options.mode == "fcomb":   options.bufsize = 4096 
     else: options.bufsize = 2048
   if not options.hopsize:
@@ -106,5 +105,4 @@
 if options.pitchmax:  params.pitchmax    = int(options.pitchmax)
 if options.pitchmin:  params.pitchmin    = int(options.pitchmin)
-if options.omode:     params.omode       = int(options.omode)
 #mintol     = float(options.mintol)*step
 # default take back system delay
Index: src/pitch/pitchdetection.c
===================================================================
--- src/pitch/pitchdetection.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ src/pitch/pitchdetection.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -31,4 +31,23 @@
 #include "pitch/pitchyinfft.h"
 #include "pitch/pitchdetection.h"
+
+/** pitch detection algorithm */
+typedef enum {
+  aubio_pitch_yin,     /**< YIN algorithm */
+  aubio_pitch_mcomb,   /**< Multi-comb filter */
+  aubio_pitch_schmitt, /**< Schmitt trigger */
+  aubio_pitch_fcomb,   /**< Fast comb filter */
+  aubio_pitch_yinfft,   /**< Spectral YIN */
+  aubio_pitch_default = aubio_pitch_yinfft, /**< the one used when "default" is asked */
+} aubio_pitchdetection_type;
+
+/** pitch detection output mode */
+typedef enum {
+  aubio_pitchm_freq,   /**< Frequency (Hz) */
+  aubio_pitchm_midi,   /**< MIDI note (0.,127) */
+  aubio_pitchm_cent,   /**< Cent */
+  aubio_pitchm_bin,    /**< Frequency bin (0,bufsize) */
+  aubio_pitchm_default = aubio_pitchm_freq, /**< the one used when "default" is asked */
+} aubio_pitchdetection_mode;
 
 typedef void (*aubio_pitchdetection_func_t)
@@ -81,15 +100,30 @@
 }
 
-aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 
-    uint_t hopsize, 
-    uint_t channels,
-    uint_t samplerate,
-    aubio_pitchdetection_type type,
-    aubio_pitchdetection_mode mode)
+aubio_pitchdetection_t *
+new_aubio_pitchdetection (char_t * pitch_mode,
+    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate)
 {
   aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t);
+  aubio_pitchdetection_type pitch_type;
+  if (strcmp (pitch_mode, "mcomb") == 0)
+      pitch_type = aubio_pitch_mcomb;
+  else if (strcmp (pitch_mode, "yinfft") == 0)
+      pitch_type = aubio_pitch_yin;
+  else if (strcmp (pitch_mode, "yin") == 0)
+      pitch_type = aubio_pitch_yin;
+  else if (strcmp (pitch_mode, "schmitt") == 0)
+      pitch_type = aubio_pitch_schmitt;
+  else if (strcmp (pitch_mode, "fcomb") == 0)
+      pitch_type = aubio_pitch_fcomb;
+  else if (strcmp (pitch_mode, "default") == 0)
+      pitch_type = aubio_pitch_default;
+  else {
+      AUBIO_ERR ("unknown pitch detection method %s, using default.\n", pitch_mode);
+      pitch_type = aubio_pitch_default;
+      return NULL;
+  }
   p->srate = samplerate;
-  p->type = type;
-  p->mode = mode;
+  p->type = pitch_type;
+  aubio_pitchdetection_set_unit (p, "default");
   p->bufsize = bufsize;
   switch(p->type) {
@@ -126,21 +160,4 @@
       break;
   }
-  switch(p->mode) {
-    case aubio_pitchm_freq:
-      p->freqconv = freqconvpass;
-      break;
-    case aubio_pitchm_midi:
-      p->freqconv = freqconvmidi;
-      break;
-    case aubio_pitchm_cent:
-      /* bug: not implemented */
-      p->freqconv = freqconvmidi;
-      break;
-    case aubio_pitchm_bin:
-      p->freqconv = freqconvbin;
-      break;
-    default:
-      break;
-  }
   return p;
 }
@@ -189,4 +206,41 @@
     }
   }
+}
+
+uint_t aubio_pitchdetection_set_unit (aubio_pitchdetection_t *p, char_t * pitch_unit) {
+  aubio_pitchdetection_mode pitch_mode;
+  if (strcmp (pitch_unit, "freq") == 0)
+      pitch_mode = aubio_pitchm_freq;
+  else if (strcmp (pitch_unit, "midi") == 0)
+      pitch_mode = aubio_pitchm_midi;
+  else if (strcmp (pitch_unit, "cent") == 0)
+      pitch_mode = aubio_pitchm_cent;
+  else if (strcmp (pitch_unit, "bin") == 0)
+      pitch_mode = aubio_pitchm_bin;
+  else if (strcmp (pitch_unit, "default") == 0)
+      pitch_mode = aubio_pitchm_default;
+  else {
+      AUBIO_ERR ("unknown pitch detection unit %s, using default\n", pitch_unit);
+      pitch_mode = aubio_pitchm_default;
+  }
+  p->mode = pitch_mode;
+  switch(p->mode) {
+    case aubio_pitchm_freq:
+      p->freqconv = freqconvpass;
+      break;
+    case aubio_pitchm_midi:
+      p->freqconv = freqconvmidi;
+      break;
+    case aubio_pitchm_cent:
+      /* bug: not implemented */
+      p->freqconv = freqconvmidi;
+      break;
+    case aubio_pitchm_bin:
+      p->freqconv = freqconvbin;
+      break;
+    default:
+      break;
+  }
+  return 0;
 }
 
Index: src/pitch/pitchdetection.h
===================================================================
--- src/pitch/pitchdetection.h	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ src/pitch/pitchdetection.h	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -32,21 +32,4 @@
 
 */
-
-/** pitch detection algorithm */
-typedef enum {
-  aubio_pitch_yin,     /**< YIN algorithm */
-  aubio_pitch_mcomb,   /**< Multi-comb filter */
-  aubio_pitch_schmitt, /**< Schmitt trigger */
-  aubio_pitch_fcomb,   /**< Fast comb filter */
-  aubio_pitch_yinfft   /**< Spectral YIN */
-} aubio_pitchdetection_type;
-
-/** pitch detection output mode */
-typedef enum {
-  aubio_pitchm_freq,   /**< Frequency (Hz) */
-  aubio_pitchm_midi,   /**< MIDI note (0.,127) */
-  aubio_pitchm_cent,   /**< Cent */
-  aubio_pitchm_bin     /**< Frequency bin (0,bufsize) */
-} aubio_pitchdetection_mode;
 
 /** pitch detection object */
@@ -85,10 +68,9 @@
 
 */
-aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize,
-    uint_t hopsize,
-    uint_t channels,
-    uint_t samplerate,
-    aubio_pitchdetection_type pitch_type,
-    aubio_pitchdetection_mode pitch_mode);
+aubio_pitchdetection_t *new_aubio_pitchdetection (char_t * pitch_mode,
+    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
+
+/** set the output unit of the pitch detection object */
+uint_t aubio_pitchdetection_set_unit (aubio_pitchdetection_t *p, char_t * pitch_unit);
 
 #ifdef __cplusplus
Index: swig/aubio.i
===================================================================
--- swig/aubio.i	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ swig/aubio.i	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -199,31 +199,10 @@
 
 /* pitch detection */
-typedef enum {
-        aubio_pitch_yin,
-        aubio_pitch_mcomb,
-        aubio_pitch_schmitt,
-        aubio_pitch_fcomb,
-        aubio_pitch_yinfft
-} aubio_pitchdetection_type;
-
-typedef enum {
-        aubio_pitchm_freq,
-        aubio_pitchm_midi,
-        aubio_pitchm_cent,
-        aubio_pitchm_bin
-} aubio_pitchdetection_mode;
-
+aubio_pitchdetection_t *new_aubio_pitchdetection (char *pitch_mode,
+    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
 void aubio_pitchdetection_do (aubio_pitchdetection_t * p, fvec_t * ibuf, fvec_t * obuf);
-
 void aubio_pitchdetection_set_tolerance(aubio_pitchdetection_t *p, smpl_t thres);
-
+void aubio_pitchdetection_set_unit(aubio_pitchdetection_t *p, char * pitch_unit);
 void del_aubio_pitchdetection(aubio_pitchdetection_t * p);
-
-aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 
-    uint_t hopsize, 
-    uint_t channels,
-    uint_t samplerate,
-    aubio_pitchdetection_type type,
-    aubio_pitchdetection_mode mode);
 
 
Index: tests/src/test-pitchdetection.c
===================================================================
--- tests/src/test-pitchdetection.c	(revision cd77c150fae93e50164a354587589c231b3f4ddc)
+++ tests/src/test-pitchdetection.c	(revision fe163ad79210270109544d4991b7130667712c8a)
@@ -1,28 +1,27 @@
 #include <aubio.h>
 
-int main(){
-        /* allocate some memory */
-        uint_t win_s      = 1024;                       /* window size */
-        uint_t hop_s      = win_s/4;                    /* hop size */
-        uint_t samplerate = 44100;                      /* samplerate */
-        uint_t channels   = 1;                          /* number of channel */
-        aubio_pitchdetection_mode mode = aubio_pitchm_freq;
-        aubio_pitchdetection_type type = aubio_pitch_yinfft;
-        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer */
-        fvec_t * out       = new_fvec (1, channels); /* input buffer */
-        aubio_pitchdetection_t * o  = new_aubio_pitchdetection(
-          win_s, hop_s, channels, samplerate, type, mode
-          );
-        uint_t i = 0;
+int
+main ()
+{
+  /* allocate some memory */
+  uint_t win_s = 1024;          /* window size */
+  uint_t hop_s = win_s / 4;     /* hop size */
+  uint_t samplerate = 44100;    /* samplerate */
+  uint_t channels = 1;          /* number of channel */
+  fvec_t *in = new_fvec (hop_s, channels);      /* input buffer */
+  fvec_t *out = new_fvec (1, channels); /* input buffer */
+  aubio_pitchdetection_t *o =
+      new_aubio_pitchdetection ("default", win_s, hop_s, channels, samplerate);
+  uint_t i = 0;
 
-        while (i < 100) {
-          aubio_pitchdetection_do (o,in, out);
-          i++;
-        };
+  while (i < 100) {
+    aubio_pitchdetection_do (o, in, out);
+    i++;
+  };
 
-        del_aubio_pitchdetection(o);
-        del_fvec(in);
-        aubio_cleanup();
+  del_aubio_pitchdetection (o);
+  del_fvec (in);
+  aubio_cleanup ();
 
-        return 0;
+  return 0;
 }
