Index: python/aubio/tasks.py
===================================================================
--- python/aubio/tasks.py	(revision 7538ac5014c2e9c4af1831e5ba63c9edff781bfe)
+++ python/aubio/tasks.py	(revision 1944aafc1d7ab59ec9a69b6c12abb7ae5249c702)
@@ -89,7 +89,7 @@
 		self.onsetmode = 'dual'
 		self.pitchmode = 'yin'
-		self.pitchsmooth = 20
+		self.pitchsmooth = 7
 		self.pitchmin=100.
-		self.pitchmax=1500.
+		self.pitchmax=1000.
 		self.dcthreshold = -1.
 		self.omode = aubio_pitchm_freq
@@ -214,11 +214,43 @@
 
 	def gettruth(self):
-		""" big hack to extract midi note from /path/to/file.<midinote>.wav """
+		""" extract ground truth array in frequency """
+		import os.path
+		""" from wavfile.txt """
+		datafile = self.input.replace('.wav','.txt')
+		if datafile == self.input: datafile = ""
+		""" from file.<midinote>.wav """
+		# FIXME very weak check
 		floatpit = self.input.split('.')[-2]
-		try:
-			return aubio_miditofreq(float(floatpit))
-		except ValueError:
-			print "ERR: no truth file found"
-			return 0
+
+		if not os.path.isfile(datafile) and not len(self.input.split('.')) < 3:
+			print "no ground truth "
+			return False,False
+		elif floatpit:
+			try:
+				self.truth = aubio_miditofreq(float(floatpit))
+				print "ground truth found in filename:", self.truth
+				tasksil = tasksilence(self.input)
+				time,pitch =[],[]
+				while(tasksil.readsize==tasksil.params.hopsize):
+					tasksil()
+					time.append(tasksil.params.step*tasksil.frameread)
+					if not tasksil.issilence:
+						pitch.append(self.truth)
+					else:
+						pitch.append(-1.)
+				return time,pitch #0,aubio_miditofreq(float(floatpit))
+			except ValueError:
+				# FIXME very weak check
+				if not os.path.isfile(datafile):
+					print "no ground truth found"
+					return 0,0
+				else:
+					from aubio.txtfile import read_datafile
+					values = read_datafile(datafile)
+					time, pitch = [], []
+					for i in range(len(values)):
+						time.append(values[i][0])
+						pitch.append(values[i][1])
+					return time,pitch
 
 	def eval(self,results):
@@ -227,10 +259,11 @@
 
 		from median import percental 
-		self.truth = self.gettruth()
+		timet,pitcht = self.gettruth()
 		res = []
 		for i in results:
+			#print i,self.truth
 			if i <= 0: pass
 			else: res.append(self.truth-i)
-		if not res: 
+		if not res or len(res) < 3: 
 			avg = self.truth; med = self.truth 
 		else:
@@ -240,6 +273,4 @@
 
 	def plot(self,pitch,wplot,oplots,outplot=None):
-		from aubio.txtfile import read_datafile
-		import os.path
 		import numarray
 		import Gnuplot
@@ -249,30 +280,23 @@
 			title=self.params.pitchmode))
 
-		# check if ground truth exists
-		datafile = self.input.replace('.wav','.txt')
-		if datafile == self.input: datafile = ""
-		if not os.path.isfile(datafile):
-			self.title = "" #"truth file not found"
-			t = Gnuplot.Data(0,0,with='impulses') 
-		else:
-			self.title = "" #"truth file plotting not implemented yet"
-			values = read_datafile(datafile)
-			if (len(datafile[0])) > 1:
-				time, pitch = [], []
-				for i in range(len(values)):
-					time.append(values[i][0])
-					pitch.append(values[i][1])
-				oplots.append(Gnuplot.Data(time,pitch,with='lines',
-					title='ground truth'))
 			
-	def plotplot(self,wplot,oplots,outplot=None):
+	def plotplot(self,wplot,oplots,outplot=None,multiplot = 1):
 		from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
 		import re
+		import Gnuplot
 		# audio data
 		time,data = audio_to_array(self.input)
 		f = make_audio_plot(time,data)
 
+		# check if ground truth exists
+		timet,pitcht = self.gettruth()
+		if timet and pitcht:
+			oplots = [Gnuplot.Data(timet,pitcht,with='lines',
+				title='ground truth')] + oplots
+
+		t = Gnuplot.Data(0,0,with='impulses') 
+
 		g = gnuplot_init(outplot)
-		g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title))
+		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
 		g('set multiplot')
 		# hack to align left axis
@@ -292,11 +316,11 @@
 		g('set origin 0,0')
 		g('set xrange [0:%f]' % max(time))
-		g('set yrange [40:%f]' % self.params.pitchmax) 
+		g('set yrange [100:%f]' % self.params.pitchmax) 
 		g('set key right top')
 		g('set noclip one') 
 		g('set format x ""')
+		g('set log y')
 		#g.xlabel('time (s)')
-		g.ylabel('frequency (Hz)')
-		multiplot = 1
+		g.ylabel('f0 (Hz)')
 		if multiplot:
 			for i in range(len(oplots)):
@@ -428,10 +452,9 @@
 		oplots.append(oplot)
 
-		# check if datafile exists truth
+		# check if ground truth datafile exists
 		datafile = self.input.replace('.wav','.txt')
 		if datafile == self.input: datafile = ""
 		if not os.path.isfile(datafile):
 			self.title = "" #"(no ground truth)"
-			t = Gnuplot.Data(0,0,with='impulses') 
 		else:
 			t_onsets = aubio.txtfile.read_datafile(datafile)
@@ -455,4 +478,5 @@
 		time,data = audio_to_array(self.input)
 		wplot = [make_audio_plot(time,data)] + wplot
+		self.title = self.input
 		# prepare the plot
 		g = gnuplot_init(outplot)
