Index: python/aubio/aubioclass.py
===================================================================
--- python/aubio/aubioclass.py	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
+++ python/aubio/aubioclass.py	(revision b31f26206b5f006b15b51aaddf5209db60560269)
@@ -77,12 +77,12 @@
         self.myfft    = cvec(bufsize,channels)
         self.pv       = pvoc(bufsize,hopsize,channels)
-        if mode in [complexdomain,hfc,phase,energy,specdiff]  :
-                self.myod     = onsetdetection(mode,bufsize,channels)
-                self.myonset  = fvec(1,channels)
-        else: 
+        if mode in ['dual'] :
                 self.myod     = onsetdetection(hfc,bufsize,channels)
                 self.myod2    = onsetdetection(complexdomain,bufsize,channels)
                 self.myonset  = fvec(1,channels)
                 self.myonset2 = fvec(1,channels)
+        else: 
+                self.myod     = onsetdetection(mode,bufsize,channels)
+                self.myonset  = fvec(1,channels)
         self.mode     = mode
         self.pp       = peakpick(float(threshold))
Index: python/aubio/gnuplot.py
===================================================================
--- python/aubio/gnuplot.py	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
+++ python/aubio/gnuplot.py	(revision b31f26206b5f006b15b51aaddf5209db60560269)
@@ -151,4 +151,6 @@
         from aubio.onsetcompare import onset_roc
 
+        if len(onsets) == 0: onsets = [0.];
+
         # onset detection function 
         downtime = (hopsize/samplerate)*numarray.arange(len(ofunc))
Index: src/onsetdetection.c
===================================================================
--- src/onsetdetection.c	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
+++ src/onsetdetection.c	(revision b31f26206b5f006b15b51aaddf5209db60560269)
@@ -68,5 +68,4 @@
 
 /* Complex Domain Method onset detection function */
-/* moved to /2 032402 */
 void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset) {
 	uint_t i, j;
@@ -128,5 +127,4 @@
 
 /* Spectral difference method onset detection function */
-/* moved to /2 032402 */
 void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o,
 		cvec_t * fftgrain, fvec_t * onset){
@@ -157,4 +155,35 @@
 }
 
+/* Kullback Liebler onset detection function
+ * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
+ * negative (1.+) and infinite values (+1.e-10) */
+void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){
+        uint_t i,j;
+        for (i=0;i<fftgrain->channels;i++) {
+                onset->data[i][0] = 0.;
+                for (j=0;j<fftgrain->length;j++) {
+                        onset->data[i][0] += fftgrain->norm[i][j]
+                                *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
+                        o->oldmag->data[i][j] = fftgrain->norm[i][j];
+                }
+                if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
+        }
+}
+
+/* Modified Kullback Liebler onset detection function
+ * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
+ * negative (1.+) and infinite values (+1.e-10) */
+void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){
+	uint_t i,j;
+	for (i=0;i<fftgrain->channels;i++) {
+		onset->data[i][0] = 0.;
+		for (j=0;j<fftgrain->length;j++) {
+			onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
+			o->oldmag->data[i][j] = fftgrain->norm[i][j];
+		}
+                if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
+	}
+}
+
 /* Generic function pointing to the choosen one */
 void 
@@ -205,4 +234,10 @@
 			o->threshold = 0.1;
 			break;
+                case kl:
+			o->oldmag = new_fvec(rsize,channels);
+                        break;
+                case mkl:
+			o->oldmag = new_fvec(rsize,channels);
+                        break;
 		default:
 			break;
@@ -228,4 +263,10 @@
 		case specdiff:
 			o->funcpointer = aubio_onsetdetection_specdiff;
+			break;
+                case kl:
+			o->funcpointer = aubio_onsetdetection_kl;
+			break;
+                case mkl:
+			o->funcpointer = aubio_onsetdetection_mkl;
 			break;
 		default:
Index: src/onsetdetection.h
===================================================================
--- src/onsetdetection.h	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
+++ src/onsetdetection.h	(revision b31f26206b5f006b15b51aaddf5209db60560269)
@@ -54,5 +54,7 @@
 	hfc,		/**< high frequency content */
 	complexdomain,  /**< complex domain */        
-	phase		/**< phase fast */            
+	phase,		/**< phase fast */            
+        kl,             /**< Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
+        mkl             /**< modified Kullback Liebler (Hainsworth et al.,  Onset detection in musical audio signals) */
 } aubio_onsetdetection_type;
 
@@ -99,4 +101,8 @@
  */
 void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+/** Kullback-Liebler onset detection function */
+void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
+/** Modified Kullback-Liebler onset detection function */
+void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
 /** Generic function pointing to the choosen one */
 void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
