Changeset 01f7598 for python/demos/demo_filter.py
- Timestamp:
- May 10, 2016, 6:50:36 PM (9 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- a4575c4
- Parents:
- 73d38d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_filter.py
r73d38d5 r01f7598 2 2 3 3 4 def apply_filter(path , params = {}):4 def apply_filter(path): 5 5 from aubio import source, sink, digital_filter 6 from os.path import basename, splitex, splitextt 6 from os.path import basename, splitext 7 8 # open input file, get its samplerate 7 9 s = source(path) 10 samplerate = s.samplerate 11 12 # create an A-weighting filter 8 13 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 f.set_a_weighting(samplerate) 15 # alternatively, apply another filter 16 17 # create output file 18 o = sink("filtered_" + splitext(basename(path))[0] + ".wav", samplerate) 19 14 20 total_frames = 0 15 16 21 while True: 17 22 samples, read = s() 18 23 filtered_samples = f(samples) 19 o( samples, read)24 o(filtered_samples, read) 20 25 total_frames += read 21 26 if read < s.hop_size: break 22 print "filtered", s.uri, "to", o.uri, "using an A-weighting filter" 27 28 duration = total_frames / float(samplerate) 29 print ("read {:s}".format(s.uri)) 30 print ("applied A-weighting filtered ({:d} Hz)".format(samplerate)) 31 print ("wrote {:s} ({:.2f} s)".format(o.uri, duration)) 23 32 24 33 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.