Index: python/demos/demo_bpm_extract.py
===================================================================
--- python/demos/demo_bpm_extract.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_bpm_extract.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -46,6 +46,12 @@
 
     # Convert to periods and to bpm 
-    bpms = 60./diff(beats)
-    b = median(bpms)
+    if len(beats) > 1:
+        if len(beats) < 4:
+            print("few beats found in {:s}".format(path))
+        bpms = 60./diff(beats)
+        b = median(bpms)
+    else:
+        b = 0
+        print("not enough beats found in {:s}".format(path))
     return b
 
@@ -54,3 +60,3 @@
     for f in sys.argv[1:]:
         bpm = get_file_bpm(f)
-        print "%6s" % ("%.2f" % bpm), f
+        print("{:6s} {:s}".format("{:2f}".format(bpm), f))
Index: python/demos/demo_filterbank.py
===================================================================
--- python/demos/demo_filterbank.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_filterbank.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -20,5 +20,5 @@
 f.set_coeffs(coeffs)
 
-times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
+times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
 title('Bank of filters built using a simple list of boundaries\nThe middle band has been amplified by 2.')
 loglog(times.T, f.get_coeffs().T, '.-')
Index: python/demos/demo_filterbank_slaney.py
===================================================================
--- python/demos/demo_filterbank_slaney.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_filterbank_slaney.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -12,5 +12,5 @@
 from pylab import loglog, title, show, xlim, ylim, xlabel, ylabel
 xlim([0,samplerate / 2])
-times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * 40)
+times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * 40)
 loglog(times.T, f.get_coeffs().T, '.-')
 title('Mel frequency bands coefficients')
Index: python/demos/demo_filterbank_triangle_bands.py
===================================================================
--- python/demos/demo_filterbank_triangle_bands.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_filterbank_triangle_bands.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -17,5 +17,5 @@
 subplot(211)
 title('Examples of filterbank built with set_triangle_bands and set_coeffs')
-times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
+times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
 loglog(times.T, f.get_coeffs().T, '.-')
 xlim([50, samplerate/2])
@@ -38,5 +38,5 @@
 
 subplot(212)
-times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
+times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
 loglog(times.T, f.get_coeffs().T, '.-')
 xlim([50, samplerate/2])
Index: python/demos/demo_mel-energy.py
===================================================================
--- python/demos/demo_mel-energy.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_mel-energy.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,8 +6,8 @@
 
 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)
 
@@ -35,6 +35,6 @@
     fftgrain = pv(samples)
     new_energies = f(fftgrain)
-    print '%f' % (total_frames / float(samplerate) ),
-    print ' '.join(['%f' % b for b in new_energies])
+    timestr = '%f' % (total_frames / float(samplerate) )
+    print('{:s} {:s}'.format(timestr, ' '.join(['%f' % b for b in new_energies])))
     energies = vstack( [energies, new_energies] )
     total_frames += read
@@ -42,5 +42,5 @@
 
 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
Index: python/demos/demo_mfcc.py
===================================================================
--- python/demos/demo_mfcc.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_mfcc.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,5 +6,5 @@
 
 win_s = 512                 # fft size
-hop_s = win_s / 4           # hop size
+hop_s = win_s // 4          # hop size
 n_filters = 40              # must be 40 for mfcc
 n_coeffs = 13
@@ -12,5 +12,5 @@
 
 if len(sys.argv) < 2:
-    print "Usage: %s <source_filename>" % sys.argv[0]
+    print("Usage: %s <source_filename>" % sys.argv[0])
     sys.exit(1)
 
Index: python/demos/demo_onset.py
===================================================================
--- python/demos/demo_onset.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_onset.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -5,8 +5,8 @@
 
 win_s = 512                 # fft size
-hop_s = win_s / 2           # hop size
+hop_s = win_s // 2          # 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)
 
@@ -29,5 +29,5 @@
     samples, read = s()
     if o(samples):
-        print "%f" % o.get_last_s()
+        print("%f" % o.get_last_s())
         onsets.append(o.get_last())
     total_frames += read
Index: python/demos/demo_onset_plot.py
===================================================================
--- python/demos/demo_onset_plot.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_onset_plot.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,8 +6,8 @@
 
 win_s = 512                 # fft size
-hop_s = win_s / 2           # hop size
+hop_s = win_s // 2          # 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)
 
@@ -35,8 +35,8 @@
     samples, read = s()
     if o(samples):
-        print "%f" % (o.get_last_s())
+        print("%f" % (o.get_last_s()))
         onsets.append(o.get_last())
     # keep some data to plot it later
-    new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
+    new_maxes = (abs(samples.reshape(hop_s//downsample, downsample))).max(axis=0)
     allsamples_max = hstack([allsamples_max, new_maxes])
     desc.append(o.get_descriptor())
@@ -62,7 +62,8 @@
     plt1.yaxis.set_visible(False)
     desc_times = [ float(t) * hop_s / samplerate for t in range(len(desc)) ]
-    desc_plot = [d / max(desc) for d in desc]
+    desc_max = max(desc) if max(desc) != 0 else 1.
+    desc_plot = [d / desc_max for d in desc]
     plt2.plot(desc_times, desc_plot, '-g')
-    tdesc_plot = [d / max(desc) for d in tdesc]
+    tdesc_plot = [d / desc_max for d in tdesc]
     for stamp in onsets:
         stamp /= float(samplerate)
Index: python/demos/demo_pitch.py
===================================================================
--- python/demos/demo_pitch.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_pitch.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -5,5 +5,5 @@
 
 if len(sys.argv) < 2:
-    print "Usage: %s <filename> [samplerate]" % sys.argv[0]
+    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
     sys.exit(1)
 
@@ -11,9 +11,9 @@
 
 downsample = 1
-samplerate = 44100 / downsample
+samplerate = 44100 // downsample
 if len( sys.argv ) > 2: samplerate = int(sys.argv[2])
 
-win_s = 4096 / downsample # fft size
-hop_s = 512  / downsample # hop size
+win_s = 4096 // downsample # fft size
+hop_s = 512  // downsample # hop size
 
 s = source(filename, samplerate, hop_s)
@@ -37,5 +37,5 @@
     confidence = pitch_o.get_confidence()
     #if confidence < 0.8: pitch = 0.
-    #print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)
+    print("%f %f %f" % (total_frames / float(samplerate), pitch, confidence))
     pitches += [pitch]
     confidences += [confidence]
Index: python/demos/demo_pitch_sinusoid.py
===================================================================
--- python/demos/demo_pitch_sinusoid.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_pitch_sinusoid.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -23,5 +23,5 @@
 freqs = np.zeros(sin_length)
 
-partition = sin_length / 8
+partition = sin_length // 8
 pointer = 0
 
@@ -45,7 +45,8 @@
     p = aubio.pitch(method, buf_size, hop_size, samplerate)
     cands[method] = run_pitch(p, a)
-    print cands[method]
+    print(method)
+    print(cands[method])
 
-print "done computing"
+print("done computing")
 
 if 1:
Index: python/demos/demo_pysoundcard_record.py
===================================================================
--- python/demos/demo_pysoundcard_record.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_pysoundcard_record.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -11,5 +11,4 @@
     s = Stream(blocksize = hop_size, channels = 1)
     g = sink(sink_path, samplerate = int(s.samplerate))
-    print s.channels
 
     s.start()
@@ -23,5 +22,6 @@
             total_frames += hop_size
     except KeyboardInterrupt:
-        print "stopped after", "%.2f seconds" % (total_frames / s.samplerate)
+        duration = total_frames / float(s.samplerate)
+        print("stopped after %.2f seconds" % duration)
     s.stop()
 
Index: python/demos/demo_simple_robot_voice.py
===================================================================
--- python/demos/demo_simple_robot_voice.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_simple_robot_voice.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,5 +6,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print 'usage: %s <inputfile> <outputfile>' % sys.argv[0]
+        print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
         sys.exit(1)
     samplerate = 44100
@@ -14,5 +14,5 @@
 
     win_s = 512                          # fft size
-    hop_s = win_s / 2                    # hop size
+    hop_s = win_s // 2                   # hop size
     pv = pvoc(win_s, hop_s)              # phase vocoder
 
@@ -26,3 +26,4 @@
         total_frames += read
 
-    print "wrote", total_frames, "from", f.uri, "to", g.uri
+    format_str = "read {:d} samples from {:s}, written to {:s}"
+    print(format_str.format(total_frames, f.uri, g.uri))
Index: python/demos/demo_simple_spectral_weighting.py
===================================================================
--- python/demos/demo_simple_spectral_weighting.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_simple_spectral_weighting.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -14,5 +14,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print 'usage: %s <inputfile> <outputfile>' % sys.argv[0]
+        print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
         sys.exit(1)
     samplerate = 0 
@@ -23,5 +23,5 @@
 
     win_s = 512 # fft size
-    hop_s = win_s / 2 # hop size
+    hop_s = win_s // 2 # hop size
     pv = pvoc(win_s, hop_s) # phase vocoder
 
@@ -31,5 +31,5 @@
         zeros( 50 ),
         1.3 * hanningz(100),
-        zeros (win_s / 2 + 1 - 40 - 50 - 100),
+        zeros (win_s // 2 + 1 - 40 - 50 - 100),
         ] )
 
@@ -53,3 +53,4 @@
         total_frames += read
 
-    print "read", total_frames / float(samplerate), "seconds from", f.uri
+    duration = total_frames / float(samplerate)
+    print("read {:.3f}s from {:s}".format(duration, f.uri))
Index: python/demos/demo_sink.py
===================================================================
--- python/demos/demo_sink.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_sink.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,5 +6,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 3:
-        print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
+        print('usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0])
         sys.exit(1)
 
@@ -23,7 +23,9 @@
         g(vec, read)
         total_frames += read
-    print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
-    print "(", total_frames, "frames", "in",
-    print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
-    print "from", f.uri,
-    print "to", g.uri
+    outstr = "wrote %.2fs" % (total_frames / float(samplerate))
+    outstr += " (%d frames in" % total_frames
+    outstr += " %d blocks" % (total_frames // f.hop_size)
+    outstr += " at %dHz)" % f.samplerate
+    outstr += " from " + f.uri
+    outstr += " to " + g.uri
+    print(outstr)
Index: python/demos/demo_sink_create_woodblock.py
===================================================================
--- python/demos/demo_sink_create_woodblock.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_sink_create_woodblock.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -3,9 +3,9 @@
 import sys
 from math import pi, e
-from aubio import sink
+from aubio import sink, float_type
 from numpy import arange, sin, exp, zeros
 
 if len(sys.argv) < 2:
-    print 'usage: %s <outputfile> [samplerate]' % sys.argv[0]
+    print('usage: %s <outputfile> [samplerate]' % sys.argv[0])
     sys.exit(1)
 
@@ -26,7 +26,7 @@
 # create a sine lookup table
 tablelen = 1000
-sinetable = arange(tablelen + 1, dtype = 'float32')
+sinetable = arange(tablelen + 1, dtype = float_type)
 sinetable = 0.7 * sin(twopi * sinetable/tablelen)
-sinetone = zeros((duration,), dtype = 'float32')
+sinetone = zeros((duration,), dtype = float_type)
 
 # compute sinetone at floating point period
@@ -40,5 +40,5 @@
 
 # apply some envelope
-float_ramp = arange(duration, dtype = 'float32')
+float_ramp = arange(duration, dtype = float_type)
 sinetone *= exp( - e * float_ramp / duration / decay)
 sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) )
Index: python/demos/demo_sink_multi.py
===================================================================
--- python/demos/demo_sink_multi.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_sink_multi.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,5 +6,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 3:
-        print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
+        print('usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0])
         sys.exit(1)
 
@@ -23,9 +23,10 @@
         g.do_multi(vec, read)
         total_frames += read
-    print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
-    print "(", total_frames, "frames", "in",
-    print total_frames / f.hop_size, "blocks",
-    print "of", f.channels, "channels",
-    print "at", "%dHz" % f.samplerate, ")",
-    print "from", f.uri,
-    print "to", g.uri
+    outstr = "wrote %.2fs" % (total_frames / float(samplerate))
+    outstr += " (%d frames in" % total_frames
+    outstr += " %d blocks" % (total_frames // f.hop_size)
+    outstr += " of %d channels" % f.channels
+    outstr += " at %dHz)" % f.samplerate
+    outstr += " from " + f.uri
+    outstr += " to " + g.uri
+    print(outstr)
Index: python/demos/demo_slicing.py
===================================================================
--- python/demos/demo_slicing.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_slicing.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -7,5 +7,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 3:
-        print 'usage: %s <inputfile> <duration>' % sys.argv[0]
+        print('usage: %s <inputfile> <duration>' % sys.argv[0])
         sys.exit(1)
     source_file = sys.argv[1]
@@ -45,6 +45,7 @@
     total_duration = total_frames_written / float(samplerate)
     slice_n += 1
-    print 'created %(slice_n)s slices from %(source_base_name)s%(source_ext)s' % locals(),
-    print ' (total duration %(total_duration).2fs)' % locals()
+    outstr = 'created %(slice_n)s slices from %(source_base_name)s%(source_ext)s' % locals()
+    outstr += ' (total duration %(total_duration).2fs)' % locals()
+    print(outstr)
     # close source and sink files
     del f, g
Index: python/demos/demo_source.py
===================================================================
--- python/demos/demo_source.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_source.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,5 +6,5 @@
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print 'usage: %s <inputfile> [samplerate] [hop_size]' % sys.argv[0]
+        print('usage: %s <inputfile> [samplerate] [hop_size]' % sys.argv[0])
         sys.exit(1)
     samplerate = 0
@@ -21,6 +21,8 @@
         total_frames += read
         if read < f.hop_size: break
-    print "read", "%.2fs" % (total_frames / float(samplerate) ),
-    print "(", total_frames, "frames", "in",
-    print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
-    print "from", f.uri
+    outstr = "read %.2fs" % (total_frames / float(samplerate))
+    outstr += " (%d frames in" % total_frames
+    outstr += " %d blocks" % (total_frames // f.hop_size)
+    outstr += " at %dHz)" % f.samplerate
+    outstr += " from " + f.uri
+    print(outstr)
Index: python/demos/demo_specdesc.py
===================================================================
--- python/demos/demo_specdesc.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_specdesc.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -2,12 +2,12 @@
 
 import sys
+import numpy as np
 from aubio import fvec, source, pvoc, specdesc
-from numpy import hstack
 
 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)
 
@@ -31,5 +31,5 @@
 for method in methods:
     cands = []
-    all_descs[method] = fvec(0)
+    all_descs[method] = np.array([])
     o[method] = specdesc(method, win_s)
 
@@ -40,15 +40,15 @@
     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
Index: python/demos/demo_spectrogram.py
===================================================================
--- python/demos/demo_spectrogram.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_spectrogram.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -2,5 +2,5 @@
 
 import sys, os.path
-from aubio import pvoc, source
+from aubio import pvoc, source, float_type
 from numpy import zeros, log10, vstack
 import matplotlib.pyplot as plt
@@ -8,11 +8,11 @@
 def get_spectrogram(filename, samplerate = 0):
     win_s = 512                                        # fft window size
-    hop_s = win_s / 2                                  # hop size
-    fft_s = win_s / 2 + 1                              # spectrum bins
+    hop_s = win_s // 2                                 # hop size
+    fft_s = win_s // 2 + 1                             # spectrum bins
 
     a = source(filename, samplerate, hop_s)            # source file
     if samplerate == 0: samplerate = a.samplerate
     pv = pvoc(win_s, hop_s)                            # phase vocoder
-    specgram = zeros([0, fft_s], dtype='float32')      # numpy array to store spectrogram
+    specgram = zeros([0, fft_s], dtype=float_type)     # numpy array to store spectrogram
 
     # analysis
@@ -29,6 +29,6 @@
     time_step = hop_s / float(samplerate)
     total_time = len(specgram) * time_step
-    print "total time: %0.2fs" % total_time,
-    print ", samplerate: %.2fkHz" % (samplerate / 1000.)
+    outstr = "total time: %0.2fs" % total_time
+    print(outstr + ", samplerate: %.2fkHz" % (samplerate / 1000.))
     n_xticks = 10
     n_yticks = 10
@@ -66,10 +66,10 @@
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print "Usage: %s <filename>" % sys.argv[0]
+        print("Usage: %s <filename>" % sys.argv[0])
     else:
         for soundfile in sys.argv[1:]:
             fig = get_spectrogram(soundfile)
             # display graph
-            fig.show()
+            plt.show()
             #outimage = os.path.basename(soundfile) + '.png'
             #print ("writing: " + outimage)
Index: python/demos/demo_tempo.py
===================================================================
--- python/demos/demo_tempo.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_tempo.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -5,8 +5,8 @@
 
 win_s = 512                 # fft size
-hop_s = win_s / 2           # hop size
+hop_s = win_s // 2          # 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)
 
@@ -34,5 +34,5 @@
     if is_beat:
         this_beat = int(total_frames - delay + is_beat[0] * hop_s)
-        print "%f" % (this_beat / float(samplerate))
+        print("%f" % (this_beat / float(samplerate)))
         beats.append(this_beat)
     total_frames += read
Index: python/demos/demo_tempo_plot.py
===================================================================
--- python/demos/demo_tempo_plot.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_tempo_plot.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -5,8 +5,8 @@
 
 win_s = 512                 # fft size
-hop_s = win_s / 2           # hop size
+hop_s = win_s // 2          # 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)
 
@@ -43,6 +43,6 @@
     import matplotlib.pyplot as plt
     bpms = 60./ diff(beats)
-    print 'mean period:', "%.2f" % mean(bpms), 'bpm', 'median', "%.2f" % median(bpms), 'bpm'
-    print 'plotting', filename
+    print('mean period: %.2fbpm, median: %.2fbpm' % (mean(bpms), median(bpms)))
+    print('plotting %s' % filename)
     plt1 = plt.axes([0.1, 0.75, 0.8, 0.19])
     plt2 = plt.axes([0.1, 0.1, 0.8, 0.65], sharex = plt1)
@@ -76,4 +76,4 @@
 
 else:
-    print 'mean period:', "%.2f" % 0, 'bpm', 'median', "%.2f" % 0, 'bpm',
-    print 'nothing to plot, file too short?'
+    print('mean period: %.2fbpm, median: %.2fbpm' % (0, 0))
+    print('plotting %s' % filename)
Index: python/demos/demo_tss.py
===================================================================
--- python/demos/demo_tss.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_tss.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -6,10 +6,10 @@
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print 'usage: %s <inputfile> <outputfile_transient> <outputfile_steady>' % sys.argv[0]
+        print('usage: %s <inputfile> <outputfile_transient> <outputfile_steady>' % sys.argv[0])
         sys.exit(1)
 
     samplerate = 44100
-    win_s = 1024      # fft size
-    hop_s = win_s / 4 # block size
+    win_s = 1024       # fft size
+    hop_s = win_s // 4 # block size
     threshold = 0.5
 
Index: python/demos/demo_waveform_plot.py
===================================================================
--- python/demos/demo_waveform_plot.py	(revision f5a0e82f0fce370955855504366ce78161a4e819)
+++ python/demos/demo_waveform_plot.py	(revision 4120fbc9a4fe29d1d7c2e25be6212014dd790086)
@@ -22,5 +22,5 @@
         samples, read = a()
         # keep some data to plot it later
-        new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
+        new_maxes = (abs(samples.reshape(hop_s//downsample, downsample))).max(axis=0)
         allsamples_max = hstack([allsamples_max, new_maxes])
         total_frames += read
@@ -49,5 +49,5 @@
     import matplotlib.pyplot as plt
     if len(sys.argv) < 2:
-        print "Usage: %s <filename>" % sys.argv[0]
+        print("Usage: %s <filename>" % sys.argv[0])
     else:
         for soundfile in sys.argv[1:]:
