Showing the changes to python (2 of 2 files). Show all
Unified · Split
| @@ -24,6 +24,9 @@ def list_files(datapath,filter='f'): · 23 unmodified lines | |||
| 24 | def list_wav_files(datapath,maxdepth=1): | 24 | def list_wav_files(datapath,maxdepth=1): |
| 25 | return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth) | 25 | return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth) |
| 26 | 26 | ||
| 27 | def list_snd_files(datapath,maxdepth=1): | ||
| 28 | return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif' -maxdepth %d"%maxdepth) | ||
| 29 | |||
| 27 | def list_dirs(datapath): | 30 | def list_dirs(datapath): |
| 28 | return list_files(datapath, filter="d") | 31 | return list_files(datapath, filter="d") |
| 29 | 32 | ||
| @@ -67,6 +67,16 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None): · 66 unmodified lines | |||
| 67 | xorig += 1./todraw | 67 | xorig += 1./todraw |
| 68 | g.gnuplot('unset multiplot;') | 68 | g.gnuplot('unset multiplot;') |
| 69 | 69 | ||
| 70 | def downsample_audio(time,data,maxpoints=10000): | ||
| 71 | """ create gnuplot plot from an audio file """ | ||
| 72 | import numarray | ||
| 73 | length = len(time) | ||
| 74 | downsample = length/maxpoints | ||
| 75 | if downsample == 0: downsample = 1 | ||
| 76 | x = numarray.array(time).resize(length)[0:-1:downsample] | ||
| 77 | y = numarray.array(data).resize(length)[0:-1:downsample] | ||
| 78 | return x,y | ||
| 79 | |||
| 70 | def make_audio_plot(time,data,maxpoints=10000): | 80 | def make_audio_plot(time,data,maxpoints=10000): |
| 71 | """ create gnuplot plot from an audio file """ | 81 | """ create gnuplot plot from an audio file """ |
| 72 | import numarray | 82 | import numarray |
| @@ -106,6 +116,7 @@ def plot_onsets(filename, onsets, ofunc, samplerate=44100., hopsize=512, outplot · 33 unmodified lines | |||
| 106 | 116 | ||
| 107 | # check if datafile exists truth | 117 | # check if datafile exists truth |
| 108 | datafile = filename.replace('.wav','.txt') | 118 | datafile = filename.replace('.wav','.txt') |
| 119 | if datafile == filename: datafile = "" | ||
| 109 | if not os.path.isfile(datafile): | 120 | if not os.path.isfile(datafile): |
| 110 | title = "truth file not found" | 121 | title = "truth file not found" |
| 111 | t = Gnuplot.Data(0,0,with='impulses') | 122 | t = Gnuplot.Data(0,0,with='impulses') |
| @@ -176,6 +187,7 @@ def plot_pitch(filename, pitch, samplerate=44100., hopsize=512, outplot=None): · 64 unmodified lines | |||
| 176 | 187 | ||
| 177 | # check if ground truth exists | 188 | # check if ground truth exists |
| 178 | datafile = filename.replace('.wav','.txt') | 189 | datafile = filename.replace('.wav','.txt') |
| 190 | if datafile == filename: datafile = "" | ||
| 179 | if not os.path.isfile(datafile): | 191 | if not os.path.isfile(datafile): |
| 180 | title = "truth file not found" | 192 | title = "truth file not found" |
| 181 | t = Gnuplot.Data(0,0,with='impulses') | 193 | t = Gnuplot.Data(0,0,with='impulses') |