python/demos/demo_specdesc.py: remove unused import
[aubio.git] / python / demos / demo_specdesc.py
index ccf27a1..6afc7f4 100755 (executable)
@@ -1,14 +1,14 @@
 #! /usr/bin/env python
 
 import sys
-from aubio import fvec, source, pvoc, specdesc
-from numpy import hstack
+import numpy as np
+from aubio import source, pvoc, specdesc
 
 win_s = 512                 # fft size
-hop_s = win_s / 4           # hop size
+hop_s = win_s // 4          # hop size
 
 if len(sys.argv) < 2:
-    print "Usage: %s <filename> [samplerate]" % sys.argv[0]
+    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
     sys.exit(1)
 
 filename = sys.argv[1]
@@ -30,7 +30,7 @@ o = {}
 
 for method in methods:
     cands = []
-    all_descs[method] = fvec(0)
+    all_descs[method] = np.array([])
     o[method] = specdesc(method, win_s)
 
 total_frames = 0
@@ -39,17 +39,17 @@ downsample = 2
 while True:
     samples, read = s()
     fftgrain = pv(samples)
-    #print "%f" % ( total_frames / float(samplerate) ),
+    #outstr = "%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
+        all_descs[method] = np.append(all_descs[method], specdesc_val)
+        #outstr += " %f" % specdesc_val
+    #print(outstr)
     total_frames += read
     if read < hop_s: break
 
 if 1:
-    print "done computing, now plotting"
+    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
@@ -71,7 +71,7 @@ if 1:
         ax.xaxis.set_visible(False)
         ax.yaxis.set_visible(False)
         ax.axis(xmax = all_desc_times[-1], xmin = all_desc_times[0])
-        ax.annotate(method, xy=(-10, 10),  xycoords='axes points',
+        ax.annotate(method, xy=(-10, 0),  xycoords='axes points',
                 horizontalalignment='right', verticalalignment='bottom',
                 )
     set_xlabels_sample2time(ax, all_desc_times[-1], samplerate)