Showing the changes to python (2 of 2 files). Show all
Unified · Split
| @@ -144,7 +144,7 @@ class taskonset(task): · 143 unmodified lines | ||
| 144 | 144 | import re |
| 145 | 145 | # prepare the plot |
| 146 | 146 | g = gnuplot_create(outplot=outplot, extension=extension) |
| 147 | − | |
| 147 | + g('set title \'%s\'' % (re.sub('.*/','',self.input))) | |
| 148 | 148 | if spectro: |
| 149 | 149 | g('set size %f,%f' % (xsize,1.3*ysize) ) |
| 150 | 150 | else: |
| @@ -154,23 +154,6 @@ class taskonset(task): · 3 unmodified lines | ||
| 154 | 154 | # hack to align left axis |
| 155 | 155 | g('set lmargin 3') |
| 156 | 156 | g('set rmargin 6') |
| 157 | − g('set tmargin 0') | |
| 158 | − g('set format x ""') | |
| 159 | − g('set format y "%3e"') | |
| 160 | − g('set noytics') | |
| 161 | − | |
| 162 | − for i in range(len(oplots)): | |
| 163 | − # plot onset detection functions | |
| 164 | − g('set size %f,%f' % (xsize,0.7*ysize/(len(oplots)))) | |
| 165 | − g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7*ysize/(len(oplots)))) | |
| 166 | − g('set xrange [0:%f]' % (self.lenofunc*self.params.step)) | |
| 167 | − g('set nokey') | |
| 168 | − g('set yrange [0:%f]' % (1.1*oplots[i][2])) | |
| 169 | − g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2]))) | |
| 170 | − g.ylabel(oplots[i][1]) | |
| 171 | − if i == len(oplots)-1: | |
| 172 | − g.xlabel('time (s)',offset=(0,0.7)) | |
| 173 | − g.plot(*oplots[i][0]) | |
| 174 | 157 | |
| 175 | 158 | if spectro: |
| 176 | 159 | import Gnuplot |
| @@ -187,36 +170,53 @@ class taskonset(task): · 10 unmodified lines | ||
| 187 | 170 | g('set rmargin 0') |
| 188 | 171 | g('set tmargin 0') |
| 189 | 172 | g('set palette rgbformulae -25,-24,-32') |
| 190 | − g.xlabel('') | |
| 173 | + g.xlabel('time (s)',offset=(0,1.)) | |
| 191 | 174 | g.ylabel('freq (Hz)') |
| 175 | + g('set origin 0,%f' % (1.0*ysize) ) | |
| 176 | + g('set format x "%1.1f"') | |
| 192 | 177 | #if log: |
| 193 | 178 | # g('set yrange [%f:%f]' % (max(10,minf),maxf)) |
| 194 | 179 | # g('set log y') |
| 195 | 180 | g.splot(Gnuplot.GridData(data,time,freq, binary=1, title='')) |
| 196 | − g('set lmargin 3') | |
| 197 | − g('set rmargin 6') | |
| 198 | − g('set origin 0,%f' % (1.0*ysize) ) | |
| 199 | − g('set format x "%1.1f"') | |
| 200 | − g.xlabel('time (s)',offset=(0,1.)) | |
| 201 | 181 | else: |
| 202 | 182 | # plot waveform and onsets |
| 183 | + time,data = audio_to_array(self.input) | |
| 184 | + wplot = [make_audio_plot(time,data)] + wplot | |
| 203 | 185 | g('set origin 0,%f' % (0.7*ysize) ) |
| 204 | − g.xlabel('time (s)',offset=(0,0.7)) | |
| 186 | + g('set size %f,%f' % (xsize,0.3*ysize)) | |
| 205 | 187 | g('set format y "%1f"') |
| 188 | + g('set xrange [0:%f]' % max(time)) | |
| 189 | + g('set yrange [-1:1]') | |
| 190 | + g('set noytics') | |
| 191 | + g('set y2tics -1,1') | |
| 192 | + g.xlabel('time (s)',offset=(0,0.7)) | |
| 193 | + g.ylabel('amplitude') | |
| 194 | + g.plot(*wplot) | |
| 206 | 195 | |
| 207 | − g('set size %f,%f' % (1.*xsize, 0.3*ysize)) | |
| 208 | − g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title)) | |
| 209 | − g('set tmargin 2') | |
| 210 | − # audio data | |
| 211 | − time,data = audio_to_array(self.input) | |
| 212 | − wplot = [make_audio_plot(time,data)] + wplot | |
| 213 | − g('set y2tics -1,1') | |
| 214 | − | |
| 215 | − g('set xrange [0:%f]' % max(time)) | |
| 216 | − g('set yrange [-1:1]') | |
| 217 | − g.ylabel('amplitude') | |
| 218 | − g.plot(*wplot) | |
| 219 | − | |
| 220 | − g('unset multiplot') | |
| 196 | + # default settings for next plots | |
| 197 | + g('unset title') | |
| 198 | + g('set format x ""') | |
| 199 | + g('set format y "%3e"') | |
| 200 | + g('set tmargin 0') | |
| 201 | + g.xlabel('') | |
| 221 | 202 | |
| 203 | + N = len(oplots) | |
| 204 | + y = 0.7*ysize # the vertical proportion of the plot taken by onset functions | |
| 205 | + delta = 0.035 # the constant part of y taken by last plot label and data | |
| 206 | + for i in range(N): | |
| 207 | + # plot onset detection functions | |
| 208 | + g('set size %f,%f' % ( xsize, (y-delta)/N)) | |
| 209 | + g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta )) | |
| 210 | + g('set nokey') | |
| 211 | + g('set xrange [0:%f]' % (self.lenofunc*self.params.step)) | |
| 212 | + g('set yrange [0:%f]' % (1.1*oplots[i][2])) | |
| 213 | + g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2]))) | |
| 214 | + g.ylabel(oplots[i][1]) | |
| 215 | + if i == N-1: | |
| 216 | + g('set size %f,%f' % ( xsize, (y-delta)/N + delta ) ) | |
| 217 | + g('set origin 0,0') | |
| 218 | + g.xlabel('time (s)', offset=(0,0.7)) | |
| 219 | + g('set format x') | |
| 220 | + g.plot(*oplots[i][0]) | |
| 222 | 221 | |
| 222 | + g('unset multiplot') | |
| @@ -161,13 +161,10 @@ class taskpitch(task): · 160 unmodified lines | ||
| 161 | 161 | titles.append(self.params.pitchmode) |
| 162 | 162 | |
| 163 | 163 | |
| 164 | − def plotplot(self,wplot,oplots,titles,outplot=None,multiplot = 1, midi = 1, truth = 1): | |
| 165 | − from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot | |
| 164 | + def plotplot(self,wplot,oplots,titles,outplot=None,extension=None,xsize=1.,ysize=1.,multiplot = 1, midi = 1, truth = 1): | |
| 165 | + from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot | |
| 166 | 166 | import re |
| 167 | 167 | import Gnuplot |
| 168 | − # audio data | |
| 169 | − time,data = audio_to_array(self.input) | |
| 170 | − f = make_audio_plot(time,data) | |
| 171 | 168 | |
| 172 | 169 | # check if ground truth exists |
| 173 | 170 | if truth: |
| @@ -176,32 +173,35 @@ class taskpitch(task): · 2 unmodified lines | ||
| 176 | 173 | oplots = [Gnuplot.Data(timet,pitcht,with='lines', |
| 177 | 174 | title='ground truth')] + oplots |
| 178 | 175 | |
| 179 | − t = Gnuplot.Data(0,0,with='impulses') | |
| 180 | − | |
| 181 | − g = gnuplot_init(outplot) | |
| 176 | + g = gnuplot_create(outplot=outplot, extension=extension) | |
| 182 | 177 | g('set title \'%s\'' % (re.sub('.*/','',self.input))) |
| 178 | + g('set size %f,%f' % (xsize,ysize) ) | |
| 183 | 179 | g('set multiplot') |
| 184 | 180 | # hack to align left axis |
| 185 | 181 | g('set lmargin 4') |
| 186 | 182 | g('set rmargin 4') |
| 187 | − # plot waveform and onsets | |
| 188 | − g('set size 1,0.3') | |
| 189 | − g('set ytics 10') | |
| 190 | − g('set origin 0,0.7') | |
| 183 | + # plot waveform | |
| 184 | + time,data = audio_to_array(self.input) | |
| 185 | + wplot = [make_audio_plot(time,data)] | |
| 186 | + g('set origin 0,%f' % (0.7*ysize) ) | |
| 187 | + g('set size %f,%f' % (xsize,0.3*ysize)) | |
| 188 | + #g('set format y "%1f"') | |
| 191 | 189 | g('set xrange [0:%f]' % max(time)) |
| 192 | 190 | g('set yrange [-1:1]') |
| 193 | 191 | g('set noytics') |
| 194 | 192 | g('set y2tics -1,1') |
| 195 | − g.xlabel('time (s)',offset=(0,0.8)) | |
| 193 | + g.xlabel('time (s)',offset=(0,0.7)) | |
| 196 | 194 | g.ylabel('amplitude') |
| 197 | − g.plot(f) | |
| 198 | − g('unset title') | |
| 199 | − # plot onset detection function | |
| 195 | + g.plot(*wplot) | |
| 200 | 196 | |
| 197 | + # default settings for next plots | |
| 198 | + g('unset title') | |
| 199 | + g('set format x ""') | |
| 200 | + g('set format y "%3e"') | |
| 201 | + g('set tmargin 0') | |
| 202 | + g.xlabel('') | |
| 203 | + g('set noclip one') | |
| 201 | 204 | |
| 202 | − g('set size 1,0.7') | |
| 203 | − g('set origin 0,0') | |
| 204 | − g('set xrange [0:%f]' % max(time)) | |
| 205 | 205 | if not midi: |
| 206 | 206 | g('set log y') |
| 207 | 207 | #g.xlabel('time (s)') |
| @@ -211,21 +211,26 @@ class taskpitch(task): · 3 unmodified lines | ||
| 211 | 211 | g.ylabel('midi') |
| 212 | 212 | g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax))) |
| 213 | 213 | g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12)) |
| 214 | − g('set key right top') | |
| 215 | − g('set noclip one') | |
| 216 | − g('set format x ""') | |
| 214 | + | |
| 217 | 215 | if multiplot: |
| 218 | − g('set tmargin 0') | |
| 219 | − for i in range(len(oplots)): | |
| 220 | − # plot onset detection functions | |
| 221 | − g('set size 1,%f' % (0.7/(len(oplots)))) | |
| 222 | − g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7/(len(oplots)))) | |
| 223 | − g('set xrange [0:%f]' % max(time)) | |
| 216 | + N = len(oplots) | |
| 217 | + y = 0.7*ysize # the vertical proportion of the plot taken by onset functions | |
| 218 | + delta = 0.035 # the constant part of y taken by last plot label and data | |
| 219 | + for i in range(N): | |
| 220 | + # plot pitch detection functions | |
| 221 | + g('set size %f,%f' % ( xsize, (y-delta)/N)) | |
| 222 | + g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta )) | |
| 224 | 223 | g('set nokey') |
| 224 | + g('set xrange [0:%f]' % max(time)) | |
| 225 | 225 | g.ylabel(titles[i]) |
| 226 | − g.xlabel('') | |
| 226 | + if i == N-1: | |
| 227 | + g('set size %f,%f' % (xsize, (y-delta)/N + delta ) ) | |
| 228 | + g('set origin 0,0') | |
| 229 | + g.xlabel('time (s)', offset=(0,0.7)) | |
| 230 | + g('set format x') | |
| 227 | 231 | g.plot(oplots[i]) |
| 228 | 232 | else: |
| 233 | + g('set key right top') | |
| 229 | 234 | g.plot(*oplots) |
| 230 | 235 | g('unset multiplot') |
| 231 | 236 | |