Changeset 83376e9


Ignore:
Timestamp:
Mar 16, 2006, 4:52:50 PM (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:
e2b1bda
Parents:
9610f0a
Message:

update task.pitch.{eval,plot}
update task.pitch.{eval,plot}

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/task/pitch.py

    r9610f0a r83376e9  
    1313                        channels=self.channels,
    1414                        samplerate=self.srate,
    15                         omode=self.params.omode)
     15                        omode=self.params.omode,
     16                        yinthresh=self.params.yinthresh)
    1617
    1718        def __call__(self):
     
    8485                                        for i in range(len(values)):
    8586                                                time.append(values[i][0])
    86                                                 pitch.append(aubio_freqtomidi(values[i][1]))
     87                                                if values[i][1] == 0.0:
     88                                                        pitch.append(-1.)
     89                                                else:
     90                                                        pitch.append(aubio_freqtomidi(values[i][1]))
    8791                                        return time,pitch
    8892
     
    105109                return self.truth, self.truth-med, self.truth-avg
    106110
    107         def eval(self,pitch,tol=0.9):
     111        def eval(self,pitch,tol=0.5):
    108112                timet,pitcht = self.gettruth()
    109113                pitch = [aubio_freqtomidi(i) for i in pitch]
     
    112116                                pitch[i] = -1
    113117                time = [ i*self.params.step for i in range(len(pitch)) ]
    114                 assert len(timet) == len(time)
     118                #print len(timet),len(pitcht)
     119                #print len(time),len(pitch)
     120                if len(timet) != len(time):
     121                        time = time[1:len(timet)+1]
     122                        pitch = pitch[1:len(pitcht)+1]
     123                        #pitcht = [aubio_freqtomidi(i) for i in pitcht]
     124                        for i in range(len(pitcht)):
     125                                if pitcht[i] == "nan" or pitcht[i] == "-inf" or pitcht[i] == -1:
     126                                        pitcht[i] = -1
     127                assert len(timet) == len(time)
    115128                assert len(pitcht) == len(pitch)
    116129                osil, esil, opit, epit, echr = 0, 0, 0, 0, 0
     
    118131                        if pitcht[i] == -1: # currently silent
    119132                                osil += 1 # count a silence
    120                                 if pitch[i] == -1. or pitch[i] == "nan":
     133                                if pitch[i] <= 0. or pitch[i] == "nan":
    121134                                        esil += 1 # found a silence
    122135                        else:
     
    138151
    139152                downtime = self.params.step*numarray.arange(len(pitch))
    140                 oplots.append(Gnuplot.Data(downtime,pitch,with='linespoints',
     153                pitch = [aubio_freqtomidi(i) for i in pitch]
     154                oplots.append(Gnuplot.Data(downtime,pitch,with='lines',
    141155                        title=self.params.pitchmode))
    142156
    143157                       
    144         def plotplot(self,wplot,oplots,outplot=None,multiplot = 0):
     158        def plotplot(self,wplot,oplots,outplot=None,multiplot = 1, midi = 1):
    145159                from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
    146160                import re
     
    153167                timet,pitcht = self.gettruth()
    154168                if timet and pitcht:
    155                         pitcht = [aubio_miditofreq(i) for i in pitcht]
    156169                        oplots = [Gnuplot.Data(timet,pitcht,with='lines',
    157170                                title='ground truth')] + oplots
     
    178191                g('set origin 0,0')
    179192                g('set xrange [0:%f]' % max(time))
    180                 g('set yrange [100:%f]' % self.params.pitchmax)
     193                if not midi:
     194                        g('set log y')
     195                        #g.xlabel('time (s)')
     196                        g.ylabel('f0 (Hz)')
     197                        g('set yrange [100:%f]' % self.params.pitchmax)
     198                else:
     199                        g.ylabel('pitch (midi)')
     200                        g('set yrange [%f:%f]' % (40, aubio_freqtomidi(self.params.pitchmax)))
    181201                g('set key right top')
    182202                g('set noclip one')
    183203                g('set format x ""')
    184                 g('set log y')
    185                 #g.xlabel('time (s)')
    186                 g.ylabel('f0 (Hz)')
    187204                if multiplot:
    188205                        for i in range(len(oplots)):
Note: See TracChangeset for help on using the changeset viewer.