Changeset 5e491b3b for python/aubio/gnuplot.py
- Timestamp:
- Aug 28, 2005, 7:58:31 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3c86eb1
- Parents:
- 4cc9fe5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
r4cc9fe5 r5e491b3b 151 151 from aubio.onsetcompare import onset_roc 152 152 153 if len(onsets) == 0: onsets = [0.]; 154 155 # onset detection function 156 downtime = (hopsize/samplerate)*numarray.arange(len(ofunc)) 157 d = Gnuplot.Data(downtime,ofunc,with='lines') 158 159 # detected onsets 160 x1 = (hopsize/samplerate)*numarray.array(onsets) 161 y1 = max(ofunc)*numarray.ones(len(onsets)) 162 e = Gnuplot.Data(x1,-y1,with='impulses') 163 e2= Gnuplot.Data(x1,y1,with='impulses') 153 d,d2 = [],[] 154 maxofunc = 0 155 for i in range(len(onsets)): 156 if len(onsets[i]) == 0: onsets[i] = [0.]; 157 158 # onset detection function 159 downtime = (hopsize/samplerate)*numarray.arange(len(ofunc[i])) 160 d.append(Gnuplot.Data(downtime,ofunc[i],with='lines')) 161 maxofunc = max(max(ofunc[i]), maxofunc) 162 163 for i in range(len(onsets)): 164 # detected onsets 165 x1 = (hopsize/samplerate)*numarray.array(onsets[i]) 166 y1 = maxofunc*numarray.ones(len(onsets[i])) 167 d.append(Gnuplot.Data(x1,y1,with='impulses')) 168 d2.append(Gnuplot.Data(x1,-y1,with='impulses')) 164 169 165 170 # check if datafile exists truth … … 170 175 else: 171 176 t_onsets = aubio.txtfile.read_datafile(datafile) 172 y2 = max (ofunc)*numarray.ones(len(t_onsets))177 y2 = maxofunc*numarray.ones(len(t_onsets)) 173 178 x2 = numarray.array(t_onsets).resize(len(t_onsets)) 174 t = Gnuplot.Data(x2,y2,with='impulses')179 d2.append(Gnuplot.Data(x2,y2,with='impulses')) 175 180 176 181 tol = 0.050 … … 189 194 # audio data 190 195 time,data = audio_to_array(filename) 191 f = make_audio_plot(time,data)196 d2.append(make_audio_plot(time,data)) 192 197 193 198 # prepare the plot … … 212 217 g('set yrange [-1:1]') 213 218 g.ylabel('amplitude') 214 g.plot( f,e,t)219 g.plot(*d2) 215 220 216 221 g('unset title') … … 219 224 g('set size 1,0.7') 220 225 g('set origin 0,0') 221 g('set xrange [0:%f]' % (hopsize/samplerate*len(ofunc )))222 g('set yrange [0:%f]' % (max (ofunc)*1.01))226 g('set xrange [0:%f]' % (hopsize/samplerate*len(ofunc[0]))) 227 g('set yrange [0:%f]' % (maxofunc*1.01)) 223 228 g.xlabel('time') 224 229 g.ylabel('onset detection value') 225 g.plot( d,e2)230 g.plot(*d) 226 231 227 232 g('unset multiplot') … … 233 238 import numarray 234 239 235 # onset detection function 236 downtime = (hopsize/samplerate)*numarray.arange(len(pitch)) 237 d = Gnuplot.Data(downtime,pitch,with='lines') 240 d = [] 241 maxpitch = 100 242 for i in range(len(pitch)): 243 downtime = (hopsize/samplerate)*numarray.arange(len(pitch[i])) 244 d.append(Gnuplot.Data(downtime,pitch[i],with='lines')) 245 maxpitch = max(maxpitch,max(pitch[i][:])*1.1) 238 246 239 247 # check if datafile exists truth … … 291 299 g('set size 1,0.7') 292 300 g('set origin 0,0') 293 g('set xrange [0:%f]' % (hopsize/samplerate*len(pitch)))294 g('set yrange [ 0:%f]' % (max(pitch)*1.01))301 g('set xrange [0:%f]' % max(time)) 302 g('set yrange [40:%f]' % maxpitch) 295 303 g.xlabel('time') 296 304 g.ylabel('frequency (Hz)') 297 g.plot( d,t)305 g.plot(*d) 298 306 299 307 g('unset multiplot')
Note: See TracChangeset
for help on using the changeset viewer.