Index: python/demos/demo_mel-energy.py
===================================================================
--- python/demos/demo_mel-energy.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
+++ python/demos/demo_mel-energy.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
@@ -0,0 +1,70 @@
+#! /usr/bin/env python
+
+import sys
+from aubio import fvec, source, pvoc, filterbank
+from numpy import vstack, zeros
+
+win_s = 512                 # fft size
+hop_s = win_s / 4           # hop size
+
+if len(sys.argv) < 2:
+    print "Usage: %s <filename> [samplerate]" % sys.argv[0]
+    sys.exit(1)
+
+filename = sys.argv[1]
+
+samplerate = 0
+if len( sys.argv ) > 2: samplerate = int(sys.argv[2])
+
+s = source(filename, samplerate, hop_s)
+samplerate = s.samplerate
+
+pv = pvoc(win_s, hop_s)
+
+f = filterbank(40, win_s)
+f.set_mel_coeffs_slaney(samplerate)
+
+energies = zeros((40,))
+o = {}
+
+total_frames = 0
+downsample = 2
+
+while True:
+    samples, read = s()
+    fftgrain = pv(samples)
+    new_energies = f(fftgrain)
+    print '%f' % (total_frames / float(samplerate) ),
+    print ' '.join(['%f' % b for b in new_energies])
+    energies = vstack( [energies, new_energies] )
+    total_frames += read
+    if read < hop_s: break
+
+if 1:
+    print "done computing, now plotting"
+    import matplotlib.pyplot as plt
+    from demo_waveform_plot import get_waveform_plot
+    from demo_waveform_plot import set_xlabels_sample2time
+    fig = plt.figure()
+    plt.rc('lines',linewidth='.8')
+    wave = plt.axes([0.1, 0.75, 0.8, 0.19])
+    get_waveform_plot(filename, samplerate, block_size = hop_s, ax = wave )
+    wave.yaxis.set_visible(False)
+    wave.xaxis.set_visible(False)
+
+    n_plots = len(energies.T)
+    all_desc_times = [ x * hop_s  for x in range(len(energies)) ]
+    for i, band in enumerate(energies.T):
+        ax = plt.axes ( [0.1, 0.75 - ((i+1) * 0.65 / n_plots),  0.8, 0.65 / n_plots], sharex = wave )
+        ax.plot(all_desc_times, band, '-', label = 'band %d' % i)
+        #ax.set_ylabel(method, rotation = 0)
+        ax.xaxis.set_visible(False)
+        ax.yaxis.set_visible(False)
+        ax.axis(xmax = all_desc_times[-1], xmin = all_desc_times[0])
+        ax.annotate('band %d' % i, xy=(-10, 10),  xycoords='axes points',
+                horizontalalignment='right', verticalalignment='bottom',
+                )
+    set_xlabels_sample2time( ax, all_desc_times[-1], samplerate) 
+    #plt.ylabel('spectral descriptor value')
+    ax.xaxis.set_visible(True)
+    plt.show()
Index: python/demos/demo_mfcc.py
===================================================================
--- python/demos/demo_mfcc.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
+++ python/demos/demo_mfcc.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
@@ -0,0 +1,68 @@
+#! /usr/bin/env python
+
+import sys
+from aubio import source, pvoc, mfcc
+from numpy import array, vstack, zeros
+
+win_s = 512                 # fft size
+hop_s = win_s / 4           # hop size
+n_filters = 40
+n_coeffs = 13
+samplerate = 44100
+
+if len(sys.argv) < 2:
+    print "Usage: %s <source_filename>" % sys.argv[0]
+    sys.exit(1)
+
+source_filename = sys.argv[1]
+
+samplerate = 0
+if len( sys.argv ) > 2: samplerate = int(sys.argv[2])
+
+s = source(source_filename, samplerate, hop_s)
+samplerate = s.samplerate
+p = pvoc(win_s, hop_s)
+m = mfcc(win_s, n_filters, n_coeffs, samplerate)
+
+desc = []
+tdesc = []
+
+mfccs = zeros([13,])
+frames_read = 0
+while True:
+    samples, read = s()
+    spec = p(samples)
+    mfcc_out = m(spec)
+    mfccs = vstack((mfccs, mfcc_out))
+    frames_read += read
+    if read < hop_s: break
+
+# do plotting
+from numpy import arange
+from demo_waveform_plot import get_waveform_plot
+from demo_waveform_plot import set_xlabels_sample2time
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+plt.rc('lines',linewidth='.8')
+wave = plt.axes([0.1, 0.75, 0.8, 0.19])
+
+get_waveform_plot( source_filename, samplerate, block_size = hop_s, ax = wave)
+wave.xaxis.set_visible(False)
+wave.yaxis.set_visible(False)
+
+all_times = arange(mfccs.shape[0]) * hop_s
+n_coeffs = mfccs.shape[1]
+for i in range(n_coeffs):
+    ax = plt.axes ( [0.1, 0.75 - ((i+1) * 0.65 / n_coeffs),  0.8, 0.65 / n_coeffs], sharex = wave )
+    ax.xaxis.set_visible(False)
+    ax.yaxis.set_visible(False)
+    ax.plot(all_times, mfccs.T[i])
+
+# add time to the last axis
+set_xlabels_sample2time( ax, frames_read, samplerate) 
+
+#plt.ylabel('spectral descriptor value')
+ax.xaxis.set_visible(True)
+wave.set_title('MFCC for %s' % source_filename)
+plt.show()
Index: python/demos/demo_specdesc.py
===================================================================
--- python/demos/demo_specdesc.py	(revision 22df684f264cd993b14996a344f08041f6f0202e)
+++ python/demos/demo_specdesc.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
@@ -22,7 +22,7 @@
 pv = pvoc(win_s, hop_s)
 
-methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl', 'mkl',
-    'specflux', 'centroid', 'spread', 'skewness', 'kurtosis', 'slope', 'decrease',
-    'rolloff', ]
+methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl',
+        'mkl', 'specflux', 'centroid', 'slope', 'rolloff', 'spread', 'skewness',
+        'kurtosis', 'decrease',]
 
 all_descs = {}
@@ -40,10 +40,10 @@
     samples, read = s()
     fftgrain = pv(samples)
-    print "%f" % ( total_frames / float(samplerate) ),
+    #print "%f" % ( total_frames / float(samplerate) ),
     for method in methods:
         specdesc_val = o[method](fftgrain)[0]
         all_descs[method] = hstack ( [all_descs[method], specdesc_val] )
-        print "%f" % specdesc_val,
-    print
+        #print "%f" % specdesc_val,
+    #print
     total_frames += read
     if read < hop_s: break
@@ -53,8 +53,9 @@
     import matplotlib.pyplot as plt
     from demo_waveform_plot import get_waveform_plot
+    from demo_waveform_plot import set_xlabels_sample2time
     fig = plt.figure()
     plt.rc('lines',linewidth='.8')
     wave = plt.axes([0.1, 0.75, 0.8, 0.19])
-    get_waveform_plot(filename, samplerate, ax = wave )
+    get_waveform_plot(filename, samplerate, block_size = hop_s, ax = wave )
     wave.yaxis.set_visible(False)
     wave.xaxis.set_visible(False)
@@ -74,10 +75,5 @@
                 horizontalalignment='right', verticalalignment='bottom',
                 )
-    if all_desc_times[-1] / float(samplerate) > 60:
-        plt.xlabel('time (mm:ss)')
-        ax.set_xticklabels([ "%02d:%02d" % (t/float(samplerate)/60, (t/float(samplerate))%60) for t in ax.get_xticks()[:-1]], rotation = 50)
-    else:
-        plt.xlabel('time (ss.mm)')
-        ax.set_xticklabels([ "%02d.%02d" % (t/float(samplerate), 100*((t/float(samplerate))%1) ) for t in ax.get_xticks()[:-1]], rotation = 50)
+    set_xlabels_sample2time(ax, all_desc_times[-1], samplerate)
     #plt.ylabel('spectral descriptor value')
     ax.xaxis.set_visible(True)
Index: python/demos/demo_waveform_plot.py
===================================================================
--- python/demos/demo_waveform_plot.py	(revision 22df684f264cd993b14996a344f08041f6f0202e)
+++ python/demos/demo_waveform_plot.py	(revision e6cde322b11d5e95519b77f873c0c598032f2826)
@@ -5,13 +5,13 @@
 from numpy import zeros, hstack
 
-def get_waveform_plot(filename, samplerate = 0, ax = None):
+def get_waveform_plot(filename, samplerate = 0, block_size = 4096, ax = None):
     import matplotlib.pyplot as plt
     if not ax:
         fig = plt.figure()
         ax = fig.add_subplot(111)
-    hop_s = 4096 # block size
+    hop_s = block_size
 
     allsamples_max = zeros(0,)
-    downsample = 2**3  # to plot n samples / hop_s
+    downsample = 2**4  # to plot n samples / hop_s
 
     a = source(filename, samplerate, hop_s)            # source file
@@ -26,6 +26,4 @@
         total_frames += read
         if read < hop_s: break
-    print samples.reshape(hop_s/downsample, downsample).shape
-
     allsamples_max = (allsamples_max > 0) * allsamples_max
     allsamples_max_times = [ ( float (t) / downsample ) * hop_s for t in range(len(allsamples_max)) ]
@@ -35,5 +33,10 @@
     ax.axis(xmin = allsamples_max_times[0], xmax = allsamples_max_times[-1])
 
-    if allsamples_max_times[-1] / float(samplerate) > 60:
+    set_xlabels_sample2time(ax, allsamples_max_times[-1], samplerate)
+    return ax
+
+def set_xlabels_sample2time(ax, latest_sample, samplerate):
+    ax.axis(xmin = 0, xmax = latest_sample)
+    if latest_sample / float(samplerate) > 60:
         ax.set_xlabel('time (mm:ss)')
         ax.set_xticklabels([ "%02d:%02d" % (t/float(samplerate)/60, (t/float(samplerate))%60) for t in ax.get_xticks()[:-1]], rotation = 50)
@@ -41,4 +44,6 @@
         ax.set_xlabel('time (ss.mm)')
         ax.set_xticklabels([ "%02d.%02d" % (t/float(samplerate), 100*((t/float(samplerate))%1) ) for t in ax.get_xticks()[:-1]], rotation = 50)
+
+
 if __name__ == '__main__':
     import matplotlib.pyplot as plt
