Skip to content

Commit

Permalink
cue_file: v1.2.3 – Limit params to sensible ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonbase59 committed Jun 4, 2024
1 parent 8980f83 commit 780758c
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions cue_file
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
# 2024-06-04 Moonbase59 - v1.2.0 Ensure all supported file types tagged safely.
# - Show Mutagen status, supported file types in help.
# - v1.2.1 Much more informative help, nicer formatting.
# - v1.2.2 Limit -t/--target input range to -23.0..0.0
# - v1.2.3 Limit all params to sensible ranges
#
# Originally based on an idea and some code by John Warburton (@Warblefly):
# https://github.com/Warblefly/TrackBoundaries

__author__ = 'Matthias C. Hormann'
__version__ = '1.2.1'
__version__ = '1.2.3'

import os
import tempfile
Expand Down Expand Up @@ -703,7 +705,7 @@ class Range(argparse.Action):

def __call__(self, parser, namespace, value, option_string=None):
if not (self.min <= value <= self.max):
msg = "invalid choice: %r (choose from [%d-%d])" % (
msg = "invalid choice: %r (range %.1f to %.1f)" % (
value,
self.min,
self.max,
Expand Down Expand Up @@ -769,35 +771,54 @@ parser.add_argument(
version='%(prog)s {version}'.format(
version=__version__))
parser.add_argument("file", help="File to be processed")
parser.add_argument("-t", "--target", help="LUFS reference target",
default=TARGET_LUFS, type=float)
parser.add_argument(
"-t",
"--target",
minimum=-23.0,
maximum=0.0,
action=Range,
default=TARGET_LUFS,
help="LUFS reference target; %(min).1f to %(max).1f",
type=float)
parser.add_argument(
"-s",
"--silence",
minimum=-96.0,
maximum=0.0,
action=Range,
default=SILENCE,
help="LU below integrated track loudness for cue-in & cue-out points "
"(silence removal at beginning & end of a track)",
default=SILENCE,
type=float)
parser.add_argument(
"-o",
"--overlay",
help="LU below integrated track loudness to trigger next track",
minimum=-96.0,
maximum=0.0,
action=Range,
default=OVERLAY_LU,
help="LU below integrated track loudness to trigger next track",
type=float)
parser.add_argument(
"-l",
"--longtail",
minimum=0.0,
maximum=60.0,
action=Range,
default=LONGTAIL_SECONDS,
help="More than so many seconds of calculated overlay duration are considered "
"a long tail, and will force a recalculation using --extra, thus keeping long "
"song endings intact",
default=LONGTAIL_SECONDS,
type=float)
parser.add_argument(
"-x",
"--extra",
minimum=-96.0,
maximum=0.0,
action=Range,
default=LONGTAIL_EXTRA_LU,
help="Extra LU below overlay loudness to trigger next track for songs "
"with long tail",
default=LONGTAIL_EXTRA_LU,
type=float)
parser.add_argument(
"-k",
Expand Down

0 comments on commit 780758c

Please sign in to comment.