Ignore:
Timestamp:
Oct 30, 2018, 1:22:44 PM (5 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:
152bf4f
Parents:
f9400d0 (diff), 4bc10e2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/docstrings

File:
1 edited

Legend:

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

    rf9400d0 red596f7  
    102102    subparser.add_input()
    103103    subparser.add_buf_hop_size()
     104    subparser.add_silence()
     105    subparser.add_release_drop()
    104106    subparser.add_time_format()
    105107    subparser.add_verbose_help()
     
    207209                action="store", dest="silence", default=-70,
    208210                help="silence threshold")
     211
     212    def add_release_drop(self):
     213        self.add_argument("-d", "--release-drop",
     214                metavar = "<value>", type=float,
     215                action="store", dest="release_drop", default=10,
     216                help="release drop threshold")
    209217
    210218    def add_minioi(self, default="12ms"):
     
    383391        self.parse_options(args, self.valid_opts)
    384392        self.notes = aubio.notes(**self.options)
     393        if args.silence is not None:
     394            self.notes.set_silence(args.silence)
     395        if args.release_drop is not None:
     396            self.notes.set_release_drop(args.release_drop)
    385397        super(process_notes, self).__init__(args)
    386398    def __call__(self, block):
     
    503515def main():
    504516    parser = aubio_parser()
    505     args = parser.parse_args()
     517    if sys.version_info[0] != 3:
     518        # on py2, create a dummy ArgumentParser to workaround the
     519        # optional subcommand issue. See https://bugs.python.org/issue9253
     520        # This ensures that:
     521        #  - version string is shown when only '-V' is passed
     522        #  - help is printed if  '-V' is passed with any other argument
     523        #  - any other argument get forwarded to the real parser
     524        parser_root = argparse.ArgumentParser(add_help=False)
     525        parser_root.add_argument('-V', '--version', help="show version",
     526                action="store_true", dest="show_version")
     527        args, extras = parser_root.parse_known_args()
     528        if args.show_version == False: # no -V, forward to parser
     529            args = parser.parse_args(extras, namespace=args)
     530        elif len(extras) != 0: # -V with other arguments, print help
     531            parser.print_help()
     532            sys.exit(1)
     533    else: # in py3, we can simply use parser directly
     534        args = parser.parse_args()
    506535    if 'show_version' in args and args.show_version:
    507536        sys.stdout.write('aubio version ' + aubio.version + '\n')
Note: See TracChangeset for help on using the changeset viewer.