def __init__(self): logging.basicConfig(level=(logging.DEBUG if LOG else logging.WARNING)) self.prefs = UserPreferences() self.player = Player() self.recorder = Recorder() self.recordhandle = None self.screenshot_generator = ScreenshotGenerator() self.websockets = [] # Used in mod-app to know when the current pedalboard changed self.pedalboard_changed_callback = lambda ok, bundlepath, title: None # Try to open real HMI hmiOpened = False if not DEV_HMI: self.hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, HMI_TIMEOUT, self.hmi_initialized_cb, self.hmi_reinit_cb) hmiOpened = self.hmi.sp is not None #print("Using HMI =>", hmiOpened) if not hmiOpened: self.hmi = FakeHMI(self.hmi_initialized_cb) print("Using FakeHMI =>", self.hmi) self.host = Host(self.hmi, self.prefs, self.msg_callback)
def __init__(self): self.ioloop = ioloop.IOLoop.instance() self.prefs = UserPreferences() self.player = Player() self.recorder = Recorder() self.recordhandle = None self.screenshot_generator = ScreenshotGenerator() self.websockets = [] # Used in mod-app to know when the current pedalboard changed self.pedalboard_changed_callback = lambda ok,bundlepath,title:None # Try to open real HMI hmiOpened = False if not DEV_HMI: self.hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, self.hmi_initialized_cb) hmiOpened = self.hmi.sp is not None print("Using HMI =>", hmiOpened) if not hmiOpened: self.hmi = FakeHMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, self.hmi_initialized_cb) self.host = Host(self.hmi, self.prefs, self.msg_callback)
def hmi_reinit_cb(self): if not os.path.exists("/usr/bin/hmi-reset"): return os.system("/usr/bin/hmi-reset; /usr/bin/sleep 3") self.hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, HMI_TIMEOUT, self.hmi_initialized_cb, self.hmi_reinit_cb) self.host.reconnect_hmi(self.hmi)
def hmi_reinit_cb(self): if not os.path.exists("/usr/bin/hmi-reset"): return # stop websockets self.hmi.initialized = False self.signal_disconnect() # restart hmi os.system("/usr/bin/hmi-reset; /usr/bin/sleep 3") # reconnect to newly started hmi self.hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, HMI_TIMEOUT, self.hmi_initialized_cb, self.hmi_reinit_cb) self.host.reconnect_hmi(self.hmi)
def __init__(self): self.host_initialized = False self._tuner = False self._tuner_port = 1 self._peakmeter = False self.monitor_server = None self.current_bank = None self.hmi_initialized = False # JACK client name of the backend self.backend_client_name = "ingen" # Used in mod-app to know when the current pedalboard changed self.pedalboard_changed_callback = lambda ok, bundlepath, title: None # For saving the current pedalboard bundlepath and title self.bundlepath = None self.title = None self.engine_samplerate = 48000 # default value self.jack_client = None self.xrun_count = 0 self.xrun_count2 = 0 self.ioloop = ioloop.IOLoop.instance() socketpath = os.environ.get("MOD_INGEN_SOCKET_URI", "unix:///tmp/ingen.sock") if DEV_HOST: self.host = FakeHost(socketpath) else: self.host = Host(socketpath) # Try to open real HMI hmiOpened = False if not DEV_HMI: self.hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, self.hmi_initialized_cb) hmiOpened = self.hmi.sp is not None print("Using HMI =>", hmiOpened) if hmiOpened: # If all ok, use addressings self.addressings = Addressing(self.hmi) else: # Otherwise disable HMI entirely self.hmi = FakeHMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, self.hmi_initialized_cb) self.addressings = None self.recorder = Recorder() self.player = Player() self.mute_state = True self.recording = None self.instances = [] self.screenshot_generator = ScreenshotGenerator() self._clipmeter = Clipmeter(self.hmi) self.websockets = [] self.mididevuuids = [] self.jack_cpu_load_timer = ioloop.PeriodicCallback( self.jack_cpu_load_timer_callback, 1000) self.jack_xrun_timer = ioloop.PeriodicCallback( self.jack_xrun_timer_callback, 500) self.ioloop.add_callback(self.init_jack) self.ioloop.add_callback(self.init_socket)
if action == SEND: print 'sending %s' % msg hmi.send(msg, consume) elif action == ASK: print msg def reply(*args): if len(queue) == 0: print "Queue empty" tornado.ioloop.IOLoop.instance().stop() hmi.send(queue.pop(0)[1]) consume() Protocol.register_cmd_callback("banks", reply) Protocol.register_cmd_callback("pedalboards", reply) Protocol.register_cmd_callback("pedalboard", reply) def start(): print "pinging" hmi.ping(consume) #hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, ping) hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, consume) application = web.Application() options.parse_command_line() tornado.ioloop.IOLoop.instance().start()