File: lbjsplay

package info (click to toggle)
laborejo 0.8~ds0-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 13,260 kB
  • ctags: 2,211
  • sloc: python: 20,735; sh: 169; makefile: 5
file content (36 lines) | stat: -rwxr-xr-x 1,758 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
parser = argparse.ArgumentParser(description="Laborejo Command Line Player.")
parser.add_argument("path", help="A Laborejo Score (*.lbjs) file")
parser.add_argument("-j", "--jack", help="Instead of the internal General Midi sample use the jack midi data set and auto-connect all lbjs-saved ports.", action="store_true")
parser.add_argument("-s", "--soundfont", help="Optional Soundfont (*.sf2). Has no effect when used with --jack")
parser.add_argument("-w", "--wait", help="Don't start playback and transport but wait for an external transport signal. Do not reset transport to 0. Default: Start transport from 0.", action="store_true")
parser.add_argument("-k", "--keeprolling", help="At the end of the song keep transporting rolling. Default: Stop transport.", action="store_true")
parser.add_argument("-i", "--introverted", help="Don't auto-connect the saved jack connections. Default: Auto-Connect.", action="store_true")


args = parser.parse_args()

import signal
import laborejocore as api #start the laborejo modile

api.calfboxInit(soundfont = args.soundfont, autoconnect = not args.introverted)

#User can quit the program before it runs out.
def signal_handler(signal, frame):
    """Abort does not listen for transport or command line options.
    It justs stops and quit"""
    api.stop()
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGQUIT, signal_handler)


api.load(args.path)
api.playOnce(jackMode = args.jack, waitForStart = args.wait, keepRolling = args.keeprolling)
print() #new line for the prompt
if args.keeprolling:
    print ("Playback finished. Jack Transport still rolling")
api.calfboxShutdown()