Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 312915
Collapse All | Expand All

(-)a/python/aubio/bench/onset.py (-6 / +12 lines)
Lines 106-117 class benchonset(bench): Link Here
106
106
107
	def plotroc(self,d,plottitle=""):
107
	def plotroc(self,d,plottitle=""):
108
		import Gnuplot, Gnuplot.funcutils
108
		import Gnuplot, Gnuplot.funcutils
109
		from aubio.compat import GnuplotData
109
		gd = []
110
		gd = []
110
		fp = []
111
		fp = []
111
		for i in self.vlist:
112
		for i in self.vlist:
112
			gd.append(i['GD']) 
113
			gd.append(i['GD']) 
113
			fp.append(i['FP']) 
114
			fp.append(i['FP']) 
114
		d.append(Gnuplot.Data(fp, gd, with='linespoints', 
115
		d.append(GnuplotData(fp, gd, with_='linespoints', 
115
			title="%s %s" % (plottitle,i['mode']) ))
116
			title="%s %s" % (plottitle,i['mode']) ))
116
117
117
	def plotplotroc(self,d,outplot=0,extension='ps'):
118
	def plotplotroc(self,d,outplot=0,extension='ps'):
Lines 142-153 class benchonset(bench): Link Here
142
143
143
	def plotpr(self,d,plottitle=""):
144
	def plotpr(self,d,plottitle=""):
144
		import Gnuplot, Gnuplot.funcutils
145
		import Gnuplot, Gnuplot.funcutils
146
		from aubio.compat import GnuplotData
145
		x = []
147
		x = []
146
		y = []
148
		y = []
147
		for i in self.vlist:
149
		for i in self.vlist:
148
			x.append(i['prec']) 
150
			x.append(i['prec']) 
149
			y.append(i['recl']) 
151
			y.append(i['recl']) 
150
		d.append(Gnuplot.Data(x, y, with='linespoints', 
152
		d.append(GnuplotData(x, y, with_='linespoints', 
151
			title="%s %s" % (plottitle,i['mode']) ))
153
			title="%s %s" % (plottitle,i['mode']) ))
152
154
153
	def plotplotpr(self,d,outplot=0,extension='ps'):
155
	def plotplotpr(self,d,outplot=0,extension='ps'):
Lines 168-178 class benchonset(bench): Link Here
168
170
169
	def plotfmeas(self,d,plottitle=""):
171
	def plotfmeas(self,d,plottitle=""):
170
		import Gnuplot, Gnuplot.funcutils
172
		import Gnuplot, Gnuplot.funcutils
173
		from aubio.compat import GnuplotData
171
		x,y = [],[]
174
		x,y = [],[]
172
		for i in self.vlist:
175
		for i in self.vlist:
173
			x.append(i['thres']) 
176
			x.append(i['thres']) 
174
			y.append(i['dist']) 
177
			y.append(i['dist']) 
175
		d.append(Gnuplot.Data(x, y, with='linespoints', 
178
		d.append(GnuplotData(x, y, with_='linespoints', 
176
			title="%s %s" % (plottitle,i['mode']) ))
179
			title="%s %s" % (plottitle,i['mode']) ))
177
180
178
	def plotplotfmeas(self,d,outplot="",extension='ps', title="F-measure"):
181
	def plotplotfmeas(self,d,outplot="",extension='ps', title="F-measure"):
Lines 201-211 class benchonset(bench): Link Here
201
204
202
	def plotfmeasvar(self,d,var,plottitle=""):
205
	def plotfmeasvar(self,d,var,plottitle=""):
203
		import Gnuplot, Gnuplot.funcutils
206
		import Gnuplot, Gnuplot.funcutils
207
		from aubio.compat import GnuplotData
204
		x,y = [],[]
208
		x,y = [],[]
205
		for i in self.vlist:
209
		for i in self.vlist:
206
			x.append(i[var]) 
210
			x.append(i[var]) 
207
			y.append(i['dist']) 
211
			y.append(i['dist']) 
208
		d.append(Gnuplot.Data(x, y, with='linespoints', 
212
		d.append(GnuplotData(x, y, with_='linespoints', 
209
			title="%s %s" % (plottitle,i['mode']) ))
213
			title="%s %s" % (plottitle,i['mode']) ))
210
	
214
	
211
	def plotplotfmeasvar(self,d,var,outplot="",extension='ps', title="F-measure"):
215
	def plotplotfmeasvar(self,d,var,outplot="",extension='ps', title="F-measure"):
Lines 228-233 class benchonset(bench): Link Here
228
232
229
	def plotdiffs(self,d,plottitle=""):
233
	def plotdiffs(self,d,plottitle=""):
230
		import Gnuplot, Gnuplot.funcutils
234
		import Gnuplot, Gnuplot.funcutils
235
		from aubio.compat import GnuplotData
231
		v = self.v
236
		v = self.v
232
		l = v['l']
237
		l = v['l']
233
		mean   = v['mean']
238
		mean   = v['mean']
Lines 244-250 class benchonset(bench): Link Here
244
		total = v['Torig']
249
		total = v['Torig']
245
		for i in range(len(per)): per[i] /= total/100.
250
		for i in range(len(per)): per[i] /= total/100.
246
251
247
		d.append(Gnuplot.Data(val, per, with='fsteps', 
252
		d.append(GnuplotData(val, per, with_='fsteps', 
248
			title="%s %s" % (plottitle,v['mode']) ))
253
			title="%s %s" % (plottitle,v['mode']) ))
249
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
254
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
250
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
255
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
Lines 272-281 class benchonset(bench): Link Here
272
277
273
	def plothistcat(self,d,plottitle=""):
278
	def plothistcat(self,d,plottitle=""):
274
		import Gnuplot, Gnuplot.funcutils
279
		import Gnuplot, Gnuplot.funcutils
280
		from aubio.compat import GnuplotData
275
		total = v['Torig']
281
		total = v['Torig']
276
		for i in range(len(per)): per[i] /= total/100.
282
		for i in range(len(per)): per[i] /= total/100.
277
283
278
		d.append(Gnuplot.Data(val, per, with='fsteps', 
284
		d.append(GnuplotData(val, per, with_='fsteps', 
279
			title="%s %s" % (plottitle,v['mode']) ))
285
			title="%s %s" % (plottitle,v['mode']) ))
280
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
286
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (mean,smean))
281
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
287
		#d.append('mean=%f,sigma=%f,eps(x) title \"\"'% (amean,samean))
(-)a/python/aubio/compat.py (+14 lines)
Line 0 Link Here
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2010 Gentoo Foundation
3
# Written by Sebastian Pipping <sebastian@pipping.org>
4
#
5
# Licensed under the same license as aubio 0.3.2
6
#
7
import Gnuplot
8
9
def GnuplotData(*args, **kwargs):
10
    """Wrapper for Python 2.6 compatibility
11
       where "with" is a reserved keyword"""
12
    kwargs['with'] = kwargs['_with']
13
    del kwargs['_with']
14
    return Gnuplot.Data(args, kwargs)
(-)a/python/aubio/gnuplot.py (-2 / +4 lines)
Lines 154-171 def downsample_audio(time,data,maxpoints=10000): Link Here
154
def make_audio_plot(time,data,maxpoints=10000):
154
def make_audio_plot(time,data,maxpoints=10000):
155
  """ create gnuplot plot from an audio file """
155
  """ create gnuplot plot from an audio file """
156
  import Gnuplot, Gnuplot.funcutils
156
  import Gnuplot, Gnuplot.funcutils
157
  from aubio.compat import GnuplotData
157
  x,y = downsample_audio(time,data,maxpoints=maxpoints)
158
  x,y = downsample_audio(time,data,maxpoints=maxpoints)
158
  return Gnuplot.Data(x,y,with='lines')
159
  return GnuplotData(x,y,with_='lines')
159
160
160
def make_audio_envelope(time,data,maxpoints=10000):
161
def make_audio_envelope(time,data,maxpoints=10000):
161
  """ create gnuplot plot from an audio file """
162
  """ create gnuplot plot from an audio file """
162
  import numarray
163
  import numarray
163
  import Gnuplot, Gnuplot.funcutils
164
  import Gnuplot, Gnuplot.funcutils
165
  from aubio.compat import GnuplotData
164
  bufsize = 500
166
  bufsize = 500
165
  x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)] 
167
  x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)] 
166
  y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)] 
168
  y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)] 
167
  x,y = downsample_audio(x,y,maxpoints=maxpoints)
169
  x,y = downsample_audio(x,y,maxpoints=maxpoints)
168
  return Gnuplot.Data(x,y,with='lines')
170
  return GnuplotData(x,y,with_='lines')
169
171
170
def gnuplot_addargs(parser):
172
def gnuplot_addargs(parser):
171
  """ add common gnuplot argument to OptParser object """
173
  """ add common gnuplot argument to OptParser object """
(-)a/python/aubio/plot/keyboard.py (-2 / +3 lines)
Lines 1-6 Link Here
1
1
2
def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
2
def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
3
  import Gnuplot
3
  import Gnuplot
4
  from aubio.compat import GnuplotData
4
  octaves = 10
5
  octaves = 10
5
6
6
  # build template of white notes
7
  # build template of white notes
Lines 30-37 def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1): Link Here
30
  yb      = [y0+(y1-y0)*2/3. for i in range(len(xb))]
31
  yb      = [y0+(y1-y0)*2/3. for i in range(len(xb))]
31
  ybdelta = [(y1-y0)*1/3. for i in range(len(xb))]
32
  ybdelta = [(y1-y0)*1/3. for i in range(len(xb))]
32
33
33
  whites  = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with = 'boxxyerrorbars')
34
  whites  = GnuplotData(xw,yw,xwdelta,ywdelta,with_='boxxyerrorbars')
34
  blacks  = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with = 'boxxyerrorbars fill solid')
35
  blacks  = GnuplotData(xb,yb,xbdelta,ybdelta,with_='boxxyerrorbars fill solid')
35
36
36
  return blacks,whites
37
  return blacks,whites
37
38
(-)a/python/aubio/task/beat.py (-2 / +4 lines)
Lines 247-262 class taskbeat(taskonset): Link Here
247
247
248
	def plot(self,oplots,results):
248
	def plot(self,oplots,results):
249
		import Gnuplot
249
		import Gnuplot
250
		oplots.append(Gnuplot.Data(results,with='linespoints',title="auto"))
250
		from aubio.compat import GnuplotData
251
		oplots.append(GnuplotData(results,with_='linespoints',title="auto"))
251
252
252
	def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False):
253
	def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False):
253
		import Gnuplot
254
		import Gnuplot
254
		from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot
255
		from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot
255
		import re
256
		import re
257
		from aubio.compat import GnuplotData
256
		# audio data
258
		# audio data
257
		#time,data = audio_to_array(self.input)
259
		#time,data = audio_to_array(self.input)
258
		#f = make_audio_plot(time,data)
260
		#f = make_audio_plot(time,data)
259
261
260
		g = gnuplot_create(outplot=outplot, extension=extension)
262
		g = gnuplot_create(outplot=outplot, extension=extension)
261
		oplots = [Gnuplot.Data(self.gettruth(),with='linespoints',title="orig")] + oplots
263
		oplots = [GnuplotData(self.gettruth(),with_='linespoints',title="orig")] + oplots
262
		g.plot(*oplots)
264
		g.plot(*oplots)
(-)a/python/aubio/task/notes.py (-5 / +7 lines)
Lines 94-115 class tasknotes(task): Link Here
94
	def plot(self,now,onset,freq,ifreq,oplots):
94
	def plot(self,now,onset,freq,ifreq,oplots):
95
		import numarray
95
		import numarray
96
		import Gnuplot
96
		import Gnuplot
97
		from aubio.compat import GnuplotData
97
98
98
		oplots.append(Gnuplot.Data(now,freq,with='lines',
99
		oplots.append(GnuplotData(now,freq,with_='lines',
99
			title=self.params.pitchmode))
100
			title=self.params.pitchmode))
100
		oplots.append(Gnuplot.Data(now,ifreq,with='lines',
101
		oplots.append(GnuplotData(now,ifreq,with_='lines',
101
			title=self.params.pitchmode))
102
			title=self.params.pitchmode))
102
103
103
		temponsets = []
104
		temponsets = []
104
		for i in onset:
105
		for i in onset:
105
			temponsets.append(i*1000)
106
			temponsets.append(i*1000)
106
		oplots.append(Gnuplot.Data(now,temponsets,with='impulses',
107
		oplots.append(GnuplotData(now,temponsets,with_='impulses',
107
			title=self.params.pitchmode))
108
			title=self.params.pitchmode))
108
109
109
	def plotplot(self,wplot,oplots,outplot=None,multiplot = 0):
110
	def plotplot(self,wplot,oplots,outplot=None,multiplot = 0):
110
		from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
111
		from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
111
		import re
112
		import re
112
		import Gnuplot
113
		import Gnuplot
114
		from aubio.compat import GnuplotData
113
		# audio data
115
		# audio data
114
		time,data = audio_to_array(self.input)
116
		time,data = audio_to_array(self.input)
115
		f = make_audio_plot(time,data)
117
		f = make_audio_plot(time,data)
Lines 117-126 class tasknotes(task): Link Here
117
		# check if ground truth exists
119
		# check if ground truth exists
118
		#timet,pitcht = self.gettruth()
120
		#timet,pitcht = self.gettruth()
119
		#if timet and pitcht:
121
		#if timet and pitcht:
120
		#	oplots = [Gnuplot.Data(timet,pitcht,with='lines',
122
		#	oplots = [GnuplotData(timet,pitcht,with_='lines',
121
		#		title='ground truth')] + oplots
123
		#		title='ground truth')] + oplots
122
124
123
		t = Gnuplot.Data(0,0,with='impulses') 
125
		t = GnuplotData(0,0,with_='impulses') 
124
126
125
		g = gnuplot_init(outplot)
127
		g = gnuplot_init(outplot)
126
		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
128
		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
(-)a/python/aubio/task/onset.py (-4 / +5 lines)
Lines 94-99 class taskonset(task): Link Here
94
		import os.path
94
		import os.path
95
		import numarray
95
		import numarray
96
		from aubio.onsetcompare import onset_roc
96
		from aubio.onsetcompare import onset_roc
97
		from aubio.compat import GnuplotData
97
98
98
		x1,y1,y1p = [],[],[]
99
		x1,y1,y1p = [],[],[]
99
		oplot = []
100
		oplot = []
Lines 103-109 class taskonset(task): Link Here
103
		self.maxofunc = max(ofunc)
104
		self.maxofunc = max(ofunc)
104
		# onset detection function 
105
		# onset detection function 
105
		downtime = numarray.arange(len(ofunc))*self.params.step
106
		downtime = numarray.arange(len(ofunc))*self.params.step
106
		oplot.append(Gnuplot.Data(downtime,ofunc,with='lines',title=self.params.onsetmode))
107
		oplot.append(GnuplotData(downtime,ofunc,with_='lines',title=self.params.onsetmode))
107
108
108
		# detected onsets
109
		# detected onsets
109
		if not nplot:
110
		if not nplot:
Lines 114-121 class taskonset(task): Link Here
114
			#x1 = numarray.array(onsets)*self.params.step
115
			#x1 = numarray.array(onsets)*self.params.step
115
			#y1 = self.maxofunc*numarray.ones(len(onsets))
116
			#y1 = self.maxofunc*numarray.ones(len(onsets))
116
			if x1:
117
			if x1:
117
				oplot.append(Gnuplot.Data(x1,y1,with='impulses'))
118
				oplot.append(GnuplotData(x1,y1,with_='impulses'))
118
				wplot.append(Gnuplot.Data(x1,y1p,with='impulses'))
119
				wplot.append(GnuplotData(x1,y1p,with_='impulses'))
119
120
120
		oplots.append((oplot,self.params.onsetmode,self.maxofunc))
121
		oplots.append((oplot,self.params.onsetmode,self.maxofunc))
121
122
Lines 128-134 class taskonset(task): Link Here
128
			t_onsets = aubio.txtfile.read_datafile(datafile)
129
			t_onsets = aubio.txtfile.read_datafile(datafile)
129
			x2 = numarray.array(t_onsets).resize(len(t_onsets))
130
			x2 = numarray.array(t_onsets).resize(len(t_onsets))
130
			y2 = self.maxofunc*numarray.ones(len(t_onsets))
131
			y2 = self.maxofunc*numarray.ones(len(t_onsets))
131
			wplot.append(Gnuplot.Data(x2,y2,with='impulses'))
132
			wplot.append(GnuplotData(x2,y2,with_='impulses'))
132
			
133
			
133
			tol = 0.050 
134
			tol = 0.050 
134
135
(-)a/python/aubio/task/pitch.py (-3 / +4 lines)
Lines 153-162 class taskpitch(task): Link Here
153
153
154
	def plot(self,pitch,wplot,oplots,titles,outplot=None):
154
	def plot(self,pitch,wplot,oplots,titles,outplot=None):
155
		import Gnuplot
155
		import Gnuplot
156
		from aubio.compat import GnuplotData
156
157
157
		time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
158
		time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
158
		pitch = [aubio_freqtomidi(i) for i in pitch]
159
		pitch = [aubio_freqtomidi(i) for i in pitch]
159
		oplots.append(Gnuplot.Data(time,pitch,with='lines',
160
		oplots.append(GnuplotData(time,pitch,with_='lines',
160
			title=self.params.pitchmode))
161
			title=self.params.pitchmode))
161
		titles.append(self.params.pitchmode)
162
		titles.append(self.params.pitchmode)
162
163
Lines 165-176 class taskpitch(task): Link Here
165
		from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot
166
		from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot
166
		import re
167
		import re
167
		import Gnuplot
168
		import Gnuplot
169
		from aubio.compat import GnuplotData
168
170
169
		# check if ground truth exists
171
		# check if ground truth exists
170
		if truth:
172
		if truth:
171
			timet,pitcht = self.gettruth()
173
			timet,pitcht = self.gettruth()
172
			if timet and pitcht:
174
			if timet and pitcht:
173
				oplots = [Gnuplot.Data(timet,pitcht,with='lines',
175
				oplots = [GnuplotData(timet,pitcht,with_='lines',
174
					title='ground truth')] + oplots
176
					title='ground truth')] + oplots
175
177
176
		g = gnuplot_create(outplot=outplot, extension=extension)
178
		g = gnuplot_create(outplot=outplot, extension=extension)
177
- 

Return to bug 312915