From: Paul Brossier Date: Wed, 19 Mar 2014 04:37:21 +0000 (-0300) Subject: python/demos/demo_a_weighting.py: add simple demo for a_weighting X-Git-Tag: 0.4.2~87 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=0b3c17bae345459e41aaf1ad5125047e732551d5;hp=cd4c9978a4b169517b48d0c6d012b13544b04503 python/demos/demo_a_weighting.py: add simple demo for a_weighting --- diff --git a/python/demos/demo_a_weighting.py b/python/demos/demo_a_weighting.py new file mode 100755 index 00000000..345e6510 --- /dev/null +++ b/python/demos/demo_a_weighting.py @@ -0,0 +1,27 @@ +#! /usr/bin/env python + + +def apply_filter(path, params = {}): + from aubio import source, sink, digital_filter + from os.path import basename, splitex, splitextt + s = source(path) + f = digital_filter(7) + f.set_a_weighting(s.samplerate) + #f = digital_filter(3) + #f.set_biquad(...) + o = sink("filtered_" + splitext(basename(path))[0] + ".wav") + # Total number of frames read + total_frames = 0 + + while True: + samples, read = s() + filtered_samples = f(samples) + o(samples, read) + total_frames += read + if read < s.hop_size: break + print "filtered", s.uri, "to", o.uri, "using an A-weighting filter" + +if __name__ == '__main__': + import sys + for f in sys.argv[1:]: + apply_filter(f)