ref: 2bd1a2a888d21384408b0c8a6ecc0b11c53fbc27
parent: f985cd607c216c7ae058a7d61acaf621227361ed
author: Paul Brossier <piem@altern.org>
date: Tue Dec 13 00:51:59 EST 2005
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
--- a/python/aubio/bench/node.py
+++ b/python/aubio/bench/node.py
@@ -24,6 +24,9 @@
def list_wav_files(datapath,maxdepth=1):
return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth)
+def list_snd_files(datapath,maxdepth=1):
+ return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif' -maxdepth %d"%maxdepth)
+
def list_dirs(datapath):
return list_files(datapath, filter="d")
--- a/python/aubio/gnuplot.py
+++ b/python/aubio/gnuplot.py
@@ -67,6 +67,16 @@
xorig += 1./todraw
g.gnuplot('unset multiplot;')
+def downsample_audio(time,data,maxpoints=10000):
+ """ create gnuplot plot from an audio file """
+ import numarray
+ length = len(time)
+ downsample = length/maxpoints
+ if downsample == 0: downsample = 1
+ x = numarray.array(time).resize(length)[0:-1:downsample]
+ y = numarray.array(data).resize(length)[0:-1:downsample]
+ return x,y
+
def make_audio_plot(time,data,maxpoints=10000):
""" create gnuplot plot from an audio file """
import numarray
@@ -106,6 +116,7 @@
# check if datafile exists truth
datafile = filename.replace('.wav','.txt')
+ if datafile == filename: datafile = ""
if not os.path.isfile(datafile):
title = "truth file not found"
t = Gnuplot.Data(0,0,with='impulses')
@@ -176,6 +187,7 @@
# check if ground truth exists
datafile = filename.replace('.wav','.txt')
+ if datafile == filename: datafile = ""
if not os.path.isfile(datafile):
title = "truth file not found"
t = Gnuplot.Data(0,0,with='impulses')