Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -10,19 +10,26 @@ def get_file_bpm(path, params = None): · 9 unmodified lines | |||
| 10 | """ | 10 | """ |
| 11 | if params is None: | 11 | if params is None: |
| 12 | params = {} | 12 | params = {} |
| 13 | try: | 13 | # default: |
| 14 | win_s = params['win_s'] | 14 | samplerate, win_s, hop_s = 44100, 1024, 512 |
| 15 | samplerate = params['samplerate'] | 15 | if 'mode' in params: |
| 16 | hop_s = params['hop_s'] | 16 | if params.mode in ['super-fast']: |
| 17 | except KeyError: | 17 | # super fast |
| 18 | """ | 18 | samplerate, win_s, hop_s = 4000, 128, 64 |
| 19 | # super fast | 19 | elif params.mode in ['fast']: |
| 20 | samplerate, win_s, hop_s = 4000, 128, 64 | 20 | # fast |
| 21 | # fast | 21 | samplerate, win_s, hop_s = 8000, 512, 128 |
| 22 | samplerate, win_s, hop_s = 8000, 512, 128 | 22 | elif params.mode in ['default']: |
| 23 | """ | 23 | pass |
| 24 | # default: | 24 | else: |
| 25 | samplerate, win_s, hop_s = 44100, 1024, 512 | 25 | print("unknown mode {:s}".format(params.mode)) |
| 26 | # manual settings | ||
| 27 | if 'samplerate' in params: | ||
| 28 | samplerate = params.samplerate | ||
| 29 | if 'win_s' in params: | ||
| 30 | win_s = params.win_s | ||
| 31 | if 'hop_s' in params: | ||
| 32 | hop_s = params.hop_s | ||
| 26 | 33 | ||
| 27 | s = source(path, samplerate, hop_s) | 34 | s = source(path, samplerate, hop_s) |
| 28 | samplerate = s.samplerate | 35 | samplerate = s.samplerate |
| @@ -56,7 +63,15 @@ def get_file_bpm(path, params = None): · 27 unmodified lines | |||
| 56 | return b | 63 | return b |
| 57 | 64 | ||
| 58 | if __name__ == '__main__': | 65 | if __name__ == '__main__': |
| 59 | import sys | 66 | import argparse |
| 60 | for f in sys.argv[1:]: | 67 | parser = argparse.ArgumentParser() |
| 61 | bpm = get_file_bpm(f) | 68 | parser.add_argument('-m', '--mode', |
| 69 | help="mode [default|fast|super-fast]", | ||
| 70 | dest="mode") | ||
| 71 | parser.add_argument('sources', | ||
| 72 | nargs='*', | ||
| 73 | help="input_files") | ||
| 74 | args = parser.parse_args() | ||
| 75 | for f in args.sources: | ||
| 76 | bpm = get_file_bpm(f, params = args) | ||
| 62 | print("{:6s} {:s}".format("{:2f}".format(bpm), f)) | 77 | print("{:6s} {:s}".format("{:2f}".format(bpm), f)) |