Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -47,7 +47,7 @@ class benchpitch(bench): · 46 unmodified lines | |||
| 47 | #print results#, computed_data | 47 | #print results#, computed_data |
| 48 | #print input, results, results - float(input.split('.')[-2]) | 48 | #print input, results, results - float(input.split('.')[-2]) |
| 49 | 49 | ||
| 50 | def run_bench(self,modes=['schmitt']): | 50 | def run_bench(self,modes=['schmitt'],multiplot=0): |
| 51 | from os.path import basename | 51 | from os.path import basename |
| 52 | self.modes = modes | 52 | self.modes = modes |
| 53 | self.pretty_titles() | 53 | self.pretty_titles() |
| @@ -90,12 +90,12 @@ class benchpitch(bench): · 36 unmodified lines | |||
| 90 | allMpit, | 90 | allMpit, |
| 91 | plottitle="%s %s" % (self.v['mode'],self.params.bufsize), | 91 | plottitle="%s %s" % (self.v['mode'],self.params.bufsize), |
| 92 | plotmode='lines') | 92 | plotmode='lines') |
| 93 | """ | ||
| 93 | self.plotpitchtessiture(plot, | 94 | self.plotpitchtessiture(plot, |
| 94 | truth, | 95 | truth, |
| 95 | allMchr, | 96 | allMchr, |
| 96 | plottitle="%s %s" % (self.v['mode'],"%12"), | 97 | plottitle="%s %s" % (self.v['mode'],"%12"), |
| 97 | plotmode='lines') | 98 | plotmode='lines') |
| 98 | """ | ||
| 99 | self.plotpitchtessiture(plot, | 99 | self.plotpitchtessiture(plot, |
| 100 | truth, | 100 | truth, |
| 101 | allMsil, | 101 | allMsil, |
| @@ -103,17 +103,20 @@ class benchpitch(bench): · 1 unmodified line | |||
| 103 | plotmode='lines') | 103 | plotmode='lines') |
| 104 | """ | 104 | """ |
| 105 | title = basename(self.datadir) | 105 | title = basename(self.datadir) |
| 106 | d.append(plot) | 106 | if multiplot: |
| 107 | d.append(plot) | ||
| 108 | else: | ||
| 109 | d += plot | ||
| 107 | outplot = "_-_".join(('pitchtessiture',title)) | 110 | outplot = "_-_".join(('pitchtessiture',title)) |
| 108 | self.xmin = 20. #min(self.v['truth']) | 111 | self.xmin = min(self.v['truth']) #20. |
| 109 | self.xmax = 110. #max(self.v['truth']) | 112 | self.xmax = max(self.v['truth']) |
| 110 | for ext in ('ps','png','svg',''): | 113 | for ext in ('ps','png','svg'): #,''): |
| 111 | self.plotplotpitchtessiture(d, | 114 | self.plotplotpitchtessiture(d, |
| 112 | plottitle="".join(['Performance against MIDI Note number (', | 115 | plottitle="".join(['Performance against MIDI Note number (', |
| 113 | title, | 116 | title, |
| 114 | ", %s" % len(self.sndlist), " samples)"]), | 117 | ", %s" % len(self.sndlist), " samples)"]), |
| 115 | outplot=outplot, | 118 | outplot=outplot, |
| 116 | extension=ext) | 119 | extension=ext,multiplot=multiplot) |
| 117 | #d.append('beta = .25,orig(x) title \"-2 octave\"') | 120 | #d.append('beta = .25,orig(x) title \"-2 octave\"') |
| 118 | #d.append('beta = .50,orig(x) title \"-1 octave\"') | 121 | #d.append('beta = .50,orig(x) title \"-1 octave\"') |
| 119 | #d.append('beta = 1.0,orig(x) title \"original\"') | 122 | #d.append('beta = 1.0,orig(x) title \"original\"') |
| @@ -132,28 +135,23 @@ class benchpitch(bench): · 12 unmodified lines | |||
| 132 | g = gnuplot_create(outplot=outplot,extension=extension) | 135 | g = gnuplot_create(outplot=outplot,extension=extension) |
| 133 | #g.title(plottitle) | 136 | #g.title(plottitle) |
| 134 | #g('orig(x) = beta*x') | 137 | #g('orig(x) = beta*x') |
| 135 | #g.xlabel('original pitch (Hz)') | 138 | g.title(plottitle) |
| 136 | #g.ylabel('detected pitch (Hz)') | 139 | g('set yrange [50:100]') |
| 137 | #g('set key left top') | 140 | # erase axis |
| 138 | #g('set log xy') | 141 | g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) |
| 139 | #g('set xrange [50:2000]') | ||
| 140 | g('set yrange [0:100]') | ||
| 141 | #g.plot(*d) | 142 | #g.plot(*d) |
| 143 | g('set border 3') | ||
| 144 | g('set xtics nomirror') | ||
| 145 | g('set ytics nomirror') | ||
| 146 | g('set key bottom') | ||
| 142 | if multiplot: | 147 | if multiplot: |
| 143 | g('set multiplot') | 148 | g('set multiplot') |
| 144 | for i in range(len(d)): | 149 | for i in range(len(d)): |
| 145 | # plot onset detection functions | 150 | # plot onset detection functions |
| 146 | g('set size 1,%f' % ( 1.0/float(len(d)) ) ) | 151 | g('set size 1,%f' % ( 1.0/float(len(d)) ) ) |
| 147 | g('set origin 0,%f' % ( 1.0*float(len(d)-i-1)/float(len(d)) ) ) | 152 | g('set origin 0,%f' % ( 1.0*float(len(d)-i-1)/float(len(d)) ) ) |
| 148 | # erase axis | ||
| 149 | g('set border 3') | ||
| 150 | g('set xtics nomirror') | ||
| 151 | g('set ytics nomirror') | ||
| 152 | g('set key left top') | ||
| 153 | g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) | ||
| 154 | #g.ylabel('%Correct detections') | 153 | #g.ylabel('%Correct detections') |
| 155 | if i == len(d)-1: | 154 | g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) |
| 156 | g.xlabel(plottitle) | ||
| 157 | g.plot(*d[i]) | 155 | g.plot(*d[i]) |
| 158 | g('unset title') | 156 | g('unset title') |
| 159 | g('unset multiplot') | 157 | g('unset multiplot') |
| @@ -168,11 +166,12 @@ if __name__ == "__main__": · 8 unmodified lines | |||
| 168 | if len(sys.argv) > 2: | 166 | if len(sys.argv) > 2: |
| 169 | for each in sys.argv[3:-1]: print each | 167 | for each in sys.argv[3:-1]: print each |
| 170 | modes = ['schmitt', 'yin', 'yinfft', 'mcomb', 'fcomb'] | 168 | modes = ['schmitt', 'yin', 'yinfft', 'mcomb', 'fcomb'] |
| 169 | #modes = ['mcomb'] | ||
| 171 | 170 | ||
| 172 | params = taskparams() | 171 | params = taskparams() |
| 173 | params.bufsize = 2048 #4096 | 172 | params.bufsize = 2048 # 4096 |
| 174 | params.hopsize = 256 | 173 | params.hopsize = 256 |
| 175 | params.silence = -70. | 174 | params.silence = -60. |
| 176 | params.pitchsmooth = 0 | 175 | params.pitchsmooth = 0 |
| 177 | params.pitchmax = 20000 | 176 | params.pitchmax = 20000 |
| 178 | params.pitchmin = 20 | 177 | params.pitchmin = 20 |