Make scale and program configurable via the command line
This commit is contained in:
parent
80e976a4ee
commit
19d3a64389
52
git-sound.py
52
git-sound.py
@ -265,7 +265,10 @@ class GitMIDI(MIDIFile):
|
|||||||
time += section_len
|
time += section_len
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='Voice of a Repo')
|
parser = argparse.ArgumentParser(description='Voice of a Repo',
|
||||||
|
epilog='Use the special value list for ' +
|
||||||
|
'scale and program to list the ' +
|
||||||
|
'available program combinations')
|
||||||
|
|
||||||
parser.add_argument('repository', type=str, nargs='?', default='.')
|
parser.add_argument('repository', type=str, nargs='?', default='.')
|
||||||
parser.add_argument('--branch',
|
parser.add_argument('--branch',
|
||||||
@ -285,15 +288,58 @@ if __name__ == '__main__':
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help="Print messages during execution")
|
help="Print messages during execution")
|
||||||
|
parser.add_argument('--scale',
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Scale to use in the generated track")
|
||||||
|
parser.add_argument('--program',
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Program setting to use in the generated track")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.scale is None and args.program != 'list':
|
||||||
|
print("Please specify a scale!")
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.program is None and args.scale != 'list':
|
||||||
|
print("Please specify a program!")
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.scale == 'list':
|
||||||
|
for scale in scales.keys():
|
||||||
|
print(scale)
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if args.program == 'list':
|
||||||
|
for program in programs.keys():
|
||||||
|
print(program)
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if args.scale not in scales:
|
||||||
|
print("{} is an unknown scale. Use 'list' to list the available scales." \
|
||||||
|
.format(args.scale))
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.program not in programs:
|
||||||
|
print(("{} is an unknown program. " +
|
||||||
|
"Use 'list' to list the available programs.") \
|
||||||
|
.format(args.program))
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
repo_midi = GitMIDI(repository=args.repository,
|
repo_midi = GitMIDI(repository=args.repository,
|
||||||
branch=args.branch,
|
branch=args.branch,
|
||||||
verbose=args.verbose,
|
verbose=args.verbose,
|
||||||
scale=scales['a-harmonic-minor'],
|
scale=scales[args.scale],
|
||||||
program=programs['sitar-tablah'])
|
program=programs[args.program])
|
||||||
|
|
||||||
except InvalidGitRepositoryError:
|
except InvalidGitRepositoryError:
|
||||||
print("{} is not a valid Git repository".format(
|
print("{} is not a valid Git repository".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user