Changeset 9b138a8


Ignore:
Timestamp:
May 17, 2006, 11:18:56 AM (18 years ago)
Author:
Paul Brossier <piem@altern.org>
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:
ba11e53
Parents:
7cded32
Message:

add spectrogram and x/y sizes to aubiocut
add spectrogram and x/y sizes to aubiocut

Location:
python
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/gnuplot.py

    r7cded32 r9b138a8  
    7373        g.gnuplot('unset multiplot;')
    7474
    75 def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = 0.):
     75def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20.):
    7676        from aubioclass import fvec,cvec,pvoc,sndfile
    7777        from math import log10
     
    135135                g('set yrange [%f:%f]' % (max(10,minf),maxf))
    136136                g('set log y')
    137         g.splot(Gnuplot.GridData(data,time,freq, binary=1, title='mag. (dB)'))
     137        g.splot(Gnuplot.GridData(data,time,freq, binary=1))
    138138        #xorig += 1./todraw
    139139
  • python/aubio/task/onset.py

    r7cded32 r9b138a8  
    140140
    141141
    142         def plotplot(self,wplot,oplots,outplot=None):
    143                 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
     142        def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False):
     143                from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot, audio_to_spec
    144144                import re
    145                 # audio data
    146                 time,data = audio_to_array(self.input)
    147                 wplot = [make_audio_plot(time,data)] + wplot
    148145                # prepare the plot
    149                 g = gnuplot_init(outplot)
    150 
     146                g = gnuplot_create(outplot=outplot, extension=extension)
     147               
     148                if spectro:
     149                        g('set size %f,%f' % (xsize,1.3*ysize) )
     150                else:
     151                        g('set size %f,%f' % (xsize,ysize) )
    151152                g('set multiplot')
    152153
     
    161162                for i in range(len(oplots)):
    162163                        # plot onset detection functions
    163                         g('set size 1,%f' % (0.7/(len(oplots))))
    164                         g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7/(len(oplots))))
     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))))
    165166                        g('set xrange [0:%f]' % (self.lenofunc*self.params.step))
    166167                        g('set nokey')
     
    172173                        g.plot(*oplots[i][0])
    173174
     175                if spectro:
     176                        import Gnuplot
     177                        minf = 50
     178                        maxf = 500
     179                        data,time,freq = audio_to_spec(self.input,minf=minf,maxf=maxf)
     180                        g('set size %f,%f' % (1.24*xsize , 0.34*ysize) )
     181                        g('set origin %f,%f' % (-0.12,0.65*ysize))
     182                        g('set xrange [0.:%f]' % time[-1])
     183                        g('set yrange [%f:%f]' % (minf,maxf))
     184                        g('set pm3d map')
     185                        g('unset colorbox')
     186                        g('set lmargin 0')
     187                        g('set rmargin 0')
     188                        g('set tmargin 0')
     189                        g('set palette rgbformulae -25,-24,-32')
     190                        g.xlabel('')
     191                        g.ylabel('freq (Hz)')
     192                        #if log:
     193                        #       g('set yrange [%f:%f]' % (max(10,minf),maxf))
     194                        #       g('set log y')
     195                        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                else:
     202                        # plot waveform and onsets
     203                        g('set origin 0,%f' % (0.7*ysize) )
     204                        g.xlabel('time (s)',offset=(0,0.7))
     205                        g('set format y "%1f"')
     206
     207                g('set size %f,%f' % (1.*xsize, 0.3*ysize))
     208                g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title))
    174209                g('set tmargin 2')
    175                 g.xlabel('time (s)',offset=(0,0.7))
    176                 g('set format x "%1.1f"')
    177                 g('set format y "%1f"')
     210                # audio data
     211                time,data = audio_to_array(self.input)
     212                wplot = [make_audio_plot(time,data)] + wplot
    178213                g('set y2tics -1,1')
    179214
    180 
    181                 g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title))
    182 
    183                 # plot waveform and onsets
    184                 g('set size 1,0.3')
    185                 g('set origin 0,0.7')
    186215                g('set xrange [0:%f]' % max(time))
    187216                g('set yrange [-1:1]')
  • python/aubiocut

    r7cded32 r9b138a8  
    6262                          action="store_true", dest="plot", default=False,
    6363                          help="draw plot")
    64         parser.add_option("-f","--function",
    65                           action="store_true", dest="func", default=False,
    66                           help="print detection function")
     64        parser.add_option("-x","--xsize",
     65                          action="store", dest="xsize", default=1.,
     66                          type='float', help="define xsize for plot")
     67        parser.add_option("-y","--ysize",
     68                          action="store", dest="ysize", default=1.,
     69                          type='float', help="define ysize for plot")
     70        parser.add_option("-f","--function",
     71                          action="store_true", dest="func", default=False,
     72                          help="print detection function")
    6773        parser.add_option("-n","--no-onsets",
    6874                          action="store_true", dest="nplot", default=False,
    69                           help="plot only detection functions")
     75                          help="do not plot detected onsets")
    7076        parser.add_option("-O","--outplot",
    7177                          action="store", dest="outplot", default=None,
    7278                          help="save plot to output.{ps,png}")
     79        parser.add_option("-F","--spectrogram",
     80                          action="store_true", dest="spectro", default=False,
     81                          help="add spectrogram to the plot")
    7382        parser.add_option("-v","--verbose",
    7483                          action="store_true", dest="verbose", default=False,
     
    131140                        print i
    132141
    133 if options.plot: filetask.plotplot(wplot, oplots, outplot=options.outplot)
     142if options.outplot:
     143  extension = options.outplot.split('.')[-1]
     144  outplot = '.'.join(options.outplot.split('.')[:-1])
     145else:
     146  extension,outplot = None,None
     147if options.plot: filetask.plotplot(wplot, oplots, outplot=outplot, extension=extension,
     148  xsize=options.xsize,ysize=options.ysize,spectro=options.spectro)
    134149
    135150if options.cut:
Note: See TracChangeset for help on using the changeset viewer.