History

python/lib/aubio/cmd.py: add some doc, prefix unused variables with _

Paul Brossier committed 9 years ago

Commit 70762c51 parent b24c9091 file · +15 −18Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t