feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 44755a0 was
0b3c17b,
checked in by Paul Brossier <piem@piem.org>, 11 years ago
|
python/demos/demo_a_weighting.py: add simple demo for a_weighting
|
-
Property mode set to
100755
|
File size:
758 bytes
|
Line | |
---|
1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | |
---|
4 | def apply_filter(path, params = {}): |
---|
5 | from aubio import source, sink, digital_filter |
---|
6 | from os.path import basename, splitex, splitextt |
---|
7 | s = source(path) |
---|
8 | f = digital_filter(7) |
---|
9 | f.set_a_weighting(s.samplerate) |
---|
10 | #f = digital_filter(3) |
---|
11 | #f.set_biquad(...) |
---|
12 | o = sink("filtered_" + splitext(basename(path))[0] + ".wav") |
---|
13 | # Total number of frames read |
---|
14 | total_frames = 0 |
---|
15 | |
---|
16 | while True: |
---|
17 | samples, read = s() |
---|
18 | filtered_samples = f(samples) |
---|
19 | o(samples, read) |
---|
20 | total_frames += read |
---|
21 | if read < s.hop_size: break |
---|
22 | print "filtered", s.uri, "to", o.uri, "using an A-weighting filter" |
---|
23 | |
---|
24 | if __name__ == '__main__': |
---|
25 | import sys |
---|
26 | for f in sys.argv[1:]: |
---|
27 | apply_filter(f) |
---|
Note: See
TracBrowser
for help on using the repository browser.