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
118118 def parser_add_subcommand_quiet(subparsers):
119119 # quiet subcommand
120120 subparser = subparsers.add_parser('quiet',
121− help='')
121+ help='extract timestamps of quiet and loud regions')
122122 parser_add_input(subparser)
123123 parser_add_hop_size(subparser)
124124 parser_add_silence(subparser)
@@ -209,7 +209,7 @@ def samples2seconds(n_frames, samplerate): · 84 unmodified lines
209209 def samples2milliseconds(n_frames, samplerate):
210210 return "%f\t" % (1000. * n_frames / float(samplerate))
211211
212−def samples2samples(n_frames, samplerate):
212+def samples2samples(n_frames, _samplerate):
213213 return "%d\t" % n_frames
214214
215215 def timefunc(mode):
@@ -271,7 +271,7 @@ class process_onset(default_process): · 55 unmodified lines
271271 super(process_onset, self).__init__(args)
272272 def __call__(self, block):
273273 return self.onset(block)
274− def repr_res(self, res, frames_read, samplerate):
274+ def repr_res(self, res, _frames_read, samplerate):
275275 if res[0] != 0:
276276 outstr = self.time2string(self.onset.get_last(), samplerate)
277277 sys.stdout.write(outstr + '\n')
@@ -302,7 +302,7 @@ class process_beat(default_process): · 24 unmodified lines
302302 super(process_beat, self).__init__(args)
303303 def __call__(self, block):
304304 return self.tempo(block)
305− def repr_res(self, res, frames_read, samplerate):
305+ def repr_res(self, res, _frames_read, samplerate):
306306 if res[0] != 0:
307307 outstr = self.time2string(self.tempo.get_last(), samplerate)
308308 sys.stdout.write(outstr + '\n')
@@ -311,7 +311,7 @@ class process_tempo(process_beat): · 2 unmodified lines
311311 def __init__(self, args):
312312 super(process_tempo, self).__init__(args)
313313 self.beat_locations = []
314− def repr_res(self, res, frames_read, samplerate):
314+ def repr_res(self, res, _frames_read, samplerate):
315315 if res[0] != 0:
316316 self.beat_locations.append(self.tempo.get_last_s())
317317 def flush(self, frames_read, samplerate):
@@ -400,7 +400,6 @@ class process_quiet(default_process): · 82 unmodified lines
400400 self.args = args
401401 valid_opts = ['hop_size', 'silence']
402402 self.parse_options(args, valid_opts)
403− self.issilence = None
404403 self.wassilence = 1
405404
406405 if args.silence is not None:
@@ -409,23 +408,21 @@ class process_quiet(default_process): · 2 unmodified lines
409408
410409 def __call__(self, block):
411410 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
417415 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
423420
424421 def repr_res(self, res, frames_read, samplerate):
425422 fmt_out = None
426− if self.issilence == -1:
423+ if res == -1:
427424 fmt_out = "NOISY: "
428− if self.issilence == 2:
425+ if res == 2:
429426 fmt_out = "QUIET: "
430427 if fmt_out is not None:
431428 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