History

add list_snd_files and downsample audio, temporary fix for filename check in plot functions add list_snd_files and downsample audio, temporary fix for filename check in plot functions

Paul Brossier committed 20 years ago

Commit 2bd1a2a1 parent f985cd62 files · +15 −0Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/aubio/bench/node.py +3 −0
  2. python/aubio/gnuplot.py +12 −0
python/aubio/bench/node.py+3−0
@@ -24,6 +24,9 @@ def list_files(datapath,filter='f'): · 23 unmodified lines
2424 def list_wav_files(datapath,maxdepth=1):
2525 return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth)
2626
27+def list_snd_files(datapath,maxdepth=1):
28+ return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif' -maxdepth %d"%maxdepth)
29+
2730 def list_dirs(datapath):
2831 return list_files(datapath, filter="d")
2932
python/aubio/gnuplot.py+12−0
@@ -67,6 +67,16 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None): · 66 unmodified lines
6767 xorig += 1./todraw
6868 g.gnuplot('unset multiplot;')
6969
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+
7080 def make_audio_plot(time,data,maxpoints=10000):
7181 """ create gnuplot plot from an audio file """
7282 import numarray
@@ -106,6 +116,7 @@ def plot_onsets(filename, onsets, ofunc, samplerate=44100., hopsize=512, outplot · 33 unmodified lines
106116
107117 # check if datafile exists truth
108118 datafile = filename.replace('.wav','.txt')
119+ if datafile == filename: datafile = ""
109120 if not os.path.isfile(datafile):
110121 title = "truth file not found"
111122 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
176187
177188 # check if ground truth exists
178189 datafile = filename.replace('.wav','.txt')
190+ if datafile == filename: datafile = ""
179191 if not os.path.isfile(datafile):
180192 title = "truth file not found"
181193 t = Gnuplot.Data(0,0,with='impulses')

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t