Changeset 70762c5 for python/lib/aubio


Ignore:
Timestamp:
Sep 14, 2017, 1:17:54 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
8a3acad
Parents:
b24c909
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cmd.py

    rb24c909 r70762c5  
    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)
     
    210210    return "%f\t" % (1000. * n_frames / float(samplerate))
    211211
    212 def samples2samples(n_frames, samplerate):
     212def samples2samples(n_frames, _samplerate):
    213213    return "%d\t" % n_frames
    214214
     
    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)
     
    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)
     
    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())
     
    401401        valid_opts = ['hop_size', 'silence']
    402402        self.parse_options(args, valid_opts)
    403         self.issilence = None
    404403        self.wassilence = 1
    405404
     
    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:
Note: See TracChangeset for help on using the changeset viewer.