Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -118,7 +118,7 @@ def parser_add_subcommand_melbands(subparsers): · 117 unmodified lines | ||
| 118 | 118 | def parser_add_subcommand_quiet(subparsers): |
| 119 | 119 | # quiet subcommand |
| 120 | 120 | subparser = subparsers.add_parser('quiet', |
| 121 | − help='') | |
| 121 | + help='extract timestamps of quiet and loud regions') | |
| 122 | 122 | parser_add_input(subparser) |
| 123 | 123 | parser_add_hop_size(subparser) |
| 124 | 124 | parser_add_silence(subparser) |
| @@ -209,7 +209,7 @@ def samples2seconds(n_frames, samplerate): · 84 unmodified lines | ||
| 209 | 209 | def samples2milliseconds(n_frames, samplerate): |
| 210 | 210 | return "%f\t" % (1000. * n_frames / float(samplerate)) |
| 211 | 211 | |
| 212 | −def samples2samples(n_frames, samplerate): | |
| 212 | +def samples2samples(n_frames, _samplerate): | |
| 213 | 213 | return "%d\t" % n_frames |
| 214 | 214 | |
| 215 | 215 | def timefunc(mode): |
| @@ -271,7 +271,7 @@ class process_onset(default_process): · 55 unmodified lines | ||
| 271 | 271 | super(process_onset, self).__init__(args) |
| 272 | 272 | def __call__(self, block): |
| 273 | 273 | return self.onset(block) |
| 274 | − def repr_res(self, res, frames_read, samplerate): | |
| 274 | + def repr_res(self, res, _frames_read, samplerate): | |
| 275 | 275 | if res[0] != 0: |
| 276 | 276 | outstr = self.time2string(self.onset.get_last(), samplerate) |
| 277 | 277 | sys.stdout.write(outstr + '\n') |
| @@ -302,7 +302,7 @@ class process_beat(default_process): · 24 unmodified lines | ||
| 302 | 302 | super(process_beat, self).__init__(args) |
| 303 | 303 | def __call__(self, block): |
| 304 | 304 | return self.tempo(block) |
| 305 | − def repr_res(self, res, frames_read, samplerate): | |
| 305 | + def repr_res(self, res, _frames_read, samplerate): | |
| 306 | 306 | if res[0] != 0: |
| 307 | 307 | outstr = self.time2string(self.tempo.get_last(), samplerate) |
| 308 | 308 | sys.stdout.write(outstr + '\n') |
| @@ -311,7 +311,7 @@ class process_tempo(process_beat): · 2 unmodified lines | ||
| 311 | 311 | def __init__(self, args): |
| 312 | 312 | super(process_tempo, self).__init__(args) |
| 313 | 313 | self.beat_locations = [] |
| 314 | − def repr_res(self, res, frames_read, samplerate): | |
| 314 | + def repr_res(self, res, _frames_read, samplerate): | |
| 315 | 315 | if res[0] != 0: |
| 316 | 316 | self.beat_locations.append(self.tempo.get_last_s()) |
| 317 | 317 | def flush(self, frames_read, samplerate): |
| @@ -400,7 +400,6 @@ class process_quiet(default_process): · 82 unmodified lines | ||
| 400 | 400 | self.args = args |
| 401 | 401 | valid_opts = ['hop_size', 'silence'] |
| 402 | 402 | self.parse_options(args, valid_opts) |
| 403 | − self.issilence = None | |
| 404 | 403 | self.wassilence = 1 |
| 405 | 404 | |
| 406 | 405 | if args.silence is not None: |
| @@ -409,23 +408,21 @@ class process_quiet(default_process): · 2 unmodified lines | ||
| 409 | 408 | |
| 410 | 409 | def __call__(self, block): |
| 411 | 410 | if aubio.silence_detection(block, self.silence) == 1: |
| 412 | − if self.wassilence == 1: | |
| 413 | − self.issilence = 1 | |
| 414 | − else: | |
| 415 | − self.issilence = 2 | |
| 416 | − self.wassilence = 1 | |
| 411 | + if self.wassilence != 1: | |
| 412 | + self.wassilence = 1 | |
| 413 | + return 2 # newly found silence | |
| 414 | + return 1 # silence again | |
| 417 | 415 | else: |
| 418 | − if self.wassilence == 0: | |
| 419 | − self.issilence = 0 | |
| 420 | − else: | |
| 421 | − self.issilence = -1 | |
| 422 | − self.wassilence = 0 | |
| 416 | + if self.wassilence != 0: | |
| 417 | + self.wassilence = 0 | |
| 418 | + return -1 # newly found noise | |
| 419 | + return 0 # noise again | |
| 423 | 420 | |
| 424 | 421 | def repr_res(self, res, frames_read, samplerate): |
| 425 | 422 | fmt_out = None |
| 426 | − if self.issilence == -1: | |
| 423 | + if res == -1: | |
| 427 | 424 | fmt_out = "NOISY: " |
| 428 | − if self.issilence == 2: | |
| 425 | + if res == 2: | |
| 429 | 426 | fmt_out = "QUIET: " |
| 430 | 427 | if fmt_out is not None: |
| 431 | 428 | fmt_out += self.time2string(frames_read, samplerate) |