History

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

Paul Brossier committed 11 years ago

Commit 193dcbb1 parent 9e54b831 file · +4 −4Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_pitch.py+4−4
@@ -22,7 +22,7 @@ samplerate = s.samplerate · 21 unmodified lines
22tolerance = 0.822tolerance = 0.8
23 23
24pitch_o = pitch("yin", win_s, hop_s, samplerate)24pitch_o = pitch("yin", win_s, hop_s, samplerate)
25pitch_o.set_unit("freq")25pitch_o.set_unit("midi")
26pitch_o.set_tolerance(tolerance)26pitch_o.set_tolerance(tolerance)
27 27
28pitches = []28pitches = []
@@ -36,7 +36,7 @@ while True: · 7 unmodified lines
36 #pitch = int(round(pitch))36 #pitch = int(round(pitch))
37 confidence = pitch_o.get_confidence()37 confidence = pitch_o.get_confidence()
38 #if confidence < 0.8: pitch = 0.38 #if confidence < 0.8: pitch = 0.
39 print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)39 #print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)
40 pitches += [pitch]40 pitches += [pitch]
41 confidences += [confidence]41 confidences += [confidence]
42 total_frames += read42 total_frames += read
@@ -80,7 +80,7 @@ if os.path.isfile(ground_truth): · 37 unmodified lines
80 ax2.plot(true_times, true_freqs, 'r')80 ax2.plot(true_times, true_freqs, 'r')
81 ax2.axis( ymin = 0.9 * true_freqs.min(), ymax = 1.1 * true_freqs.max() )81 ax2.axis( ymin = 0.9 * true_freqs.min(), ymax = 1.1 * true_freqs.max() )
82# plot raw pitches82# plot raw pitches
83ax2.plot(times, pitches, '--g')83ax2.plot(times, pitches, '.g')
84# plot cleaned up pitches84# plot cleaned up pitches
85cleaned_pitches = pitches85cleaned_pitches = pitches
86#cleaned_pitches = ma.masked_where(cleaned_pitches < 0, cleaned_pitches)86#cleaned_pitches = ma.masked_where(cleaned_pitches < 0, cleaned_pitches)
@@ -90,7 +90,7 @@ ax2.plot(times, cleaned_pitches, '.-') · 3 unmodified lines
90#ax2.axis( ymin = 0.9 * cleaned_pitches.min(), ymax = 1.1 * cleaned_pitches.max() )90#ax2.axis( ymin = 0.9 * cleaned_pitches.min(), ymax = 1.1 * cleaned_pitches.max() )
91#ax2.axis( ymin = 55, ymax = 70 )91#ax2.axis( ymin = 55, ymax = 70 )
92plt.setp(ax2.get_xticklabels(), visible = False)92plt.setp(ax2.get_xticklabels(), visible = False)
93ax2.set_ylabel('f0 (Hz)')93ax2.set_ylabel('f0 (midi)')
94 94
95# plot confidence95# plot confidence
96ax3 = fig.add_subplot(313, sharex = ax1)96ax3 = fig.add_subplot(313, sharex = ax1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t