Showing the changes to python/demos (1 of 1 file). Show all
Unified · Split
| @@ -4,6 +4,7 @@ import sys · 3 unmodified lines | |||
| 4 | import os.path | 4 | import os.path |
| 5 | import aubio | 5 | import aubio |
| 6 | 6 | ||
| 7 | |||
| 7 | def apply_filter(path, target): | 8 | def apply_filter(path, target): |
| 8 | # open input file, get its samplerate | 9 | # open input file, get its samplerate |
| 9 | s = aubio.source(path) | 10 | s = aubio.source(path) |
| @@ -27,19 +28,20 @@ def apply_filter(path, target): · 17 unmodified lines | |||
| 27 | # count frames read | 28 | # count frames read |
| 28 | total_frames += read | 29 | total_frames += read |
| 29 | # end of file reached | 30 | # end of file reached |
| 30 | if read < s.hop_size: break | 31 | if read < s.hop_size: |
| 32 | break | ||
| 31 | 33 | ||
| 32 | # print some info | 34 | # print some info |
| 33 | duration = total_frames / float(samplerate) | 35 | duration = total_frames / float(samplerate) |
| 34 | input_str = "input: {:s} ({:.2f} s, {:d} Hz)" | 36 | input_str = "input: {:s} ({:.2f} s, {:d} Hz)" |
| 35 | output_str = "output: {:s}, A-weighting filtered ({:d} frames total)" | 37 | output_str = "output: {:s}, A-weighting filtered ({:d} frames total)" |
| 36 | print (input_str.format(s.uri, duration, samplerate)) | 38 | print(input_str.format(s.uri, duration, samplerate)) |
| 37 | print (output_str.format(o.uri, total_frames)) | 39 | print(output_str.format(o.uri, total_frames)) |
| 38 | 40 | ||
| 39 | if __name__ == '__main__': | 41 | if __name__ == '__main__': |
| 40 | usage = "{:s} <input_file> [output_file]".format(sys.argv[0]) | 42 | usage = "{:s} <input_file> [output_file]".format(sys.argv[0]) |
| 41 | if not 1 < len(sys.argv) < 4: | 43 | if not 1 < len(sys.argv) < 4: |
| 42 | print (usage) | 44 | print(usage) |
| 43 | sys.exit(1) | 45 | sys.exit(1) |
| 44 | if len(sys.argv) < 3: | 46 | if len(sys.argv) < 3: |
| 45 | input_path = sys.argv[1] | 47 | input_path = sys.argv[1] |