From 2bd1a2a888d21384408b0c8a6ecc0b11c53fbc27 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 13 Dec 2005 05:51:59 +0000 Subject: [PATCH] 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 --- python/aubio/bench/node.py | 3 +++ python/aubio/gnuplot.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/python/aubio/bench/node.py b/python/aubio/bench/node.py index ca337b0a..91318ee7 100644 --- a/python/aubio/bench/node.py +++ b/python/aubio/bench/node.py @@ -24,6 +24,9 @@ def list_files(datapath,filter='f'): 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") diff --git a/python/aubio/gnuplot.py b/python/aubio/gnuplot.py index dc100db5..9c0ec42e 100644 --- a/python/aubio/gnuplot.py +++ b/python/aubio/gnuplot.py @@ -67,6 +67,16 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None): 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 @@ def plot_onsets(filename, onsets, ofunc, samplerate=44100., hopsize=512, outplot # 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 @@ def plot_pitch(filename, pitch, samplerate=44100., hopsize=512, outplot=None): # 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') -- 2.26.2