diff options
author | Owen Williams <owilliams@mixxx.org> | 2015-04-16 22:36:16 -0400 |
---|---|---|
committer | Owen Williams <owilliams@mixxx.org> | 2015-04-16 22:37:08 -0400 |
commit | 4a0159f43218833e23d0882349b05f1903cd8275 (patch) | |
tree | 7160a29a2c2c5934013f5a86a768e0eb08596008 /scripts | |
parent | cfd461301da13631cd9abefc139ea0bcd53565c6 (diff) |
Create a framework for testing actual output of the enginebuffer.
After a call to ProcessBuffer(), tests can now compare the contents
of the output buffer against a golden data file representing expected
output. This is useful for catching regressions in the engine code
as well as seeing how changes in the engine code affect audio output.
Included in this commit is a script called AudioPlot.py which has
been very useful to me in the past for analyzing audio data. It
requires matplotlib to be installed.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/AudioPlot.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/scripts/AudioPlot.py b/scripts/AudioPlot.py new file mode 100755 index 0000000000..bb663f45a1 --- /dev/null +++ b/scripts/AudioPlot.py @@ -0,0 +1,92 @@ +#!/usr/bin/python + +from matplotlib import pyplot as plt +from matplotlib.lines import Line2D +import time, string, glob, sys + +import getopt + +def AudioPlot(f, columns): + colors = ['g','c','b','m','r'] + plt.figure() + + #set up dictionary of lists + if columns != "all": + data = {} + for c in columns: + data[c] = [] + else: + data = None + + #build the individual columns + for line in f.readlines(): + splitted = line.split(",") + if columns == "all" and data is None: + #make list of columns based on number of entries in first line + columns = [i for i in range(0,len(splitted))] + data = {} + for c in columns: + data[c] = [] + + for c in columns: + data[c].append(splitted[c].strip()) + + i=0 + + for c in columns: + print "another column" + normalized = [] + for d in data[c]: + try: + normalized.append(float(d)) + except: + print "skipping ", d + #rotate through my five favorite colors + plt.plot(normalized, colors[i % len(colors)]) + i+=1 + + plt.show() + + return + +def usage(): + print """ +AudioPlot.py: +-c pick column to plot (more than one is OK, 1-based indexes, or "all") +-f file to plot from +""" + +if __name__ == "__main__": + columns = [] + fname = None + try: + opts, args = getopt.getopt(sys.argv[1:], "c:f:",[]) + for o, a in opts: + if o == "-c": + if columns != "all": + if a.upper() == "ALL": + columns = "all" + else: + columns.append(int(a)-1) + elif o == "-f": + fname = a + else: + print "usage??" + usage() + sys.exit(1) + except Exception, e: + print str(e) + usage() + sys.exit(1) + + if fname is None: + usage() + sys.exit(1) + + try: + f = open(fname, "r") + except Exception, e: + print "Error opening file %s: %s" % (fname, str(e)) + sys.exit(1) + + AudioPlot(f, columns) |