shithub: aubio

Download patch

ref: 193dcbb9a1412067b126aeffaf84bb66ee7027ba
parent: 9e54b835d105443375d270f2b40408579828e714
author: Paul Brossier <piem@piem.org>
date: Tue May 26 07:01:57 EDT 2015

python/demos/demo_pitch.py: remove stdout, plot in midi

--- a/python/demos/demo_pitch.py
+++ b/python/demos/demo_pitch.py
@@ -22,7 +22,7 @@
 tolerance = 0.8
 
 pitch_o = pitch("yin", win_s, hop_s, samplerate)
-pitch_o.set_unit("freq")
+pitch_o.set_unit("midi")
 pitch_o.set_tolerance(tolerance)
 
 pitches = []
@@ -36,7 +36,7 @@
     #pitch = int(round(pitch))
     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]
     total_frames += read
@@ -80,7 +80,7 @@
     ax2.plot(true_times, true_freqs, 'r')
     ax2.axis( ymin = 0.9 * true_freqs.min(), ymax = 1.1 * true_freqs.max() )
 # plot raw pitches
-ax2.plot(times, pitches, '--g')
+ax2.plot(times, pitches, '.g')
 # plot cleaned up pitches
 cleaned_pitches = pitches
 #cleaned_pitches = ma.masked_where(cleaned_pitches < 0, cleaned_pitches)
@@ -90,7 +90,7 @@
 #ax2.axis( ymin = 0.9 * cleaned_pitches.min(), ymax = 1.1 * cleaned_pitches.max() )
 #ax2.axis( ymin = 55, ymax = 70 )
 plt.setp(ax2.get_xticklabels(), visible = False)
-ax2.set_ylabel('f0 (Hz)')
+ax2.set_ylabel('f0 (midi)')
 
 # plot confidence
 ax3 = fig.add_subplot(313, sharex = ax1)