Exemplo n.º 1
0
def replaygain():
    init_gstreamer()
    optparser = rgain_options()
    opts, args = optparser.parse_args()
    if not args:
        optparser.error("pass one or several audio file names")

    if opts.show:
        show_rgain_info(args, opts.mp3_format)
    else:
        try:
            do_gain(args, opts.ref_level, opts.force, opts.dry_run, opts.album,
                    opts.mp3_format)
        except Error as exc:
            print("")
            print(str(exc), file=sys.stderr)
            sys.exit(1)
        except KeyboardInterrupt:
            print("Interrupted.")
Exemplo n.º 2
0
def collectiongain():
    init_gstreamer()
    optparser = collectiongain_options()
    opts, args = optparser.parse_args()
    if len(args) != 1:
        optparser.error("pass one directory path")
    if opts.jobs is not None and opts.jobs < 1:
        optparser.error("jobs must be at least 1")
    if opts.regain:
        opts.force = opts.ignore_cache = True

    try:
        do_collectiongain(args[0], opts.ref_level, opts.force, opts.dry_run,
                          opts.mp3_format, opts.ignore_cache, opts.jobs)
    except Error as exc:
        print("")
        print(str(exc), file=sys.stderr)
        sys.exit(1)
    except KeyboardInterrupt:
        print("Interrupted.")
Exemplo n.º 3
0
from gi.repository import GLib
from rgain3 import rgcalc, util
from rgain3.script import init_gstreamer

ref_level = 89
init_gstreamer()


# mostly copy/pasted from rgain3 source
# adapted for Rainwave usage
def get_gain_for_song(file):
    exceptions = []

    # handlers
    def on_finished(evsrc, trackdata, albumdata):
        loop.quit()

    def on_error(evsrc, exc):
        exceptions.append(exc)
        loop.quit()

    rg = rgcalc.ReplayGain([file], True, ref_level)
    with util.gobject_signals(
            rg,
        ("all-finished", on_finished),
        ("error", on_error),
    ):
        loop = GLib.MainLoop()
        rg.start()
        loop.run()