Esempio n. 1
0
    def process_file(self, data, callback=lambda:None):
        filename = os.path.join(self.destination_dir, data['filename'])

        if not os.path.exists(filename):
            callback()
            return

        if not os.path.exists(self.destination_dir):
            os.mkdir(self.destination_dir)

        # FIXME - don't use external tools!
        from subprocess import getoutput
        tar_output = getoutput('env LANG=C tar -xvf "%s" -C "%s"' % (filename, self.destination_dir))
        bundlepath = os.path.join(self.destination_dir, tar_output.strip().split("\n", 1)[0])

        if not os.path.exists(bundlepath):
            raise IOError(bundlepath)

        # make sure pedalboard is valid
        name = get_pedalboard_name(bundlepath)

        SESSION.load_pedalboard(bundlepath, name)

        os.remove(filename)
        callback()
Esempio n. 2
0
 def get(self, instance):
     instance = instance
     x = int(float(self.get_argument('x')))
     y = int(float(self.get_argument('y')))
     SESSION.effect_position(instance, x, y)
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 3
0
def check_environment(callback):
    from mod.settings import (HARDWARE_DIR,
                              DEVICE_SERIAL, DEVICE_MODEL,
                              DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR)
    from mod import indexing
    from mod.session import SESSION

    for dirname in (HARDWARE_DIR, DOWNLOAD_TMP_DIR):
        if not os.path.exists(dirname):
            os.makedirs(dirname)

    if not os.path.exists(BANKS_JSON_FILE):
        fh = open(BANKS_JSON_FILE, 'w')
        fh.write("[]")
        fh.close()

    # TEMPORARIO, APENAS NO DESENVOLVIMENTO
    if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL):
        serial = open(DEVICE_SERIAL).read()
        model = re.search('^[A-Z]+').group()
        open(DEVICE_MODEL, 'w').write(model)

    def ping_callback(ok):
        if ok:
            pass
        else:
            # calls ping again every one second
            ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))
    SESSION.ping(ping_callback)
Esempio n. 4
0
    def process_file(self, data, callback=lambda: None):
        filename = os.path.join(self.destination_dir, data['filename'])

        if not os.path.exists(filename):
            callback()
            return

        if not os.path.exists(self.destination_dir):
            os.mkdir(self.destination_dir)

        # FIXME - don't use external tools!
        from subprocess import getoutput
        tar_output = getoutput('env LANG=C tar -xvf "%s" -C "%s"' %
                               (filename, self.destination_dir))
        bundlepath = os.path.join(self.destination_dir,
                                  tar_output.strip().split("\n", 1)[0])

        if not os.path.exists(bundlepath):
            raise IOError(bundlepath)

        # make sure pedalboard is valid
        name = get_pedalboard_name(bundlepath)

        SESSION.load_pedalboard(bundlepath, name)

        os.remove(filename)
        callback()
Esempio n. 5
0
    def slot_backendStartPhase2(self):
        if self.fProccessBackend.state() == QProcess.NotRunning:
            return

        if not self.fNeedsSessionReconnect:
            # we'll need it for next time
            self.fNeedsSessionReconnect = True
        else:
            # we need it now
            SESSION.reconnectApp()

        self.fWebServerThread.start()
Esempio n. 6
0
    def post(self):
        upload = self.request.files['package'][0]

        with open(os.path.join(DOWNLOAD_TMP_DIR, upload['filename']), 'wb') as fh:
            fh.write(b64decode(upload['body']))

        resp = yield gen.Task(install_package, upload['filename'])

        if resp['ok']:
            SESSION.msg_callback("rescan " + b64encode(json.dumps(resp).encode("utf-8")).decode("utf-8"))

        self.write(resp)
Esempio n. 7
0
    def slot_backendStartPhase2(self):
        if self.fProccessBackend.state() == QProcess.NotRunning:
            return

        if not self.fNeedsSessionReconnect:
            # we'll need it for next time
            self.fNeedsSessionReconnect = True
        else:
            # we need it now
            SESSION.reconnectApp()

        self.fWebServerThread.start()
Esempio n. 8
0
def check_environment(callback):
    from mod.settings import (EFFECT_DIR, HARDWARE_DIR, INDEX_PATH,
                              DEVICE_SERIAL, DEVICE_MODEL,
                              DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR)
    from mod import indexing
    from mod.session import SESSION

    for dirname in (EFFECT_DIR, HARDWARE_DIR, DOWNLOAD_TMP_DIR):
        if not os.path.exists(dirname):
            os.makedirs(dirname)

    if not os.path.exists(BANKS_JSON_FILE):
        fh = open(BANKS_JSON_FILE, 'w')
        fh.write("[]")
        fh.close()

    # Index creation will check consistency and rebuild index if necessary
    effect_index = indexing.EffectIndex()

    # Migrations. Since we don't have a migration mechanism, let's do it here
    # TODO Migration system where we'll have migration scripts that will be marked as
    # already executed
    for effect_id in os.listdir(EFFECT_DIR):
        if effect_id.endswith('.metadata'):
            continue
        path = os.path.join(EFFECT_DIR, '%s.metadata' % effect_id)
        metadata = {}
        try:
            if os.path.exists(path):
                metadata = json.loads(open(path).read())
        except:
            pass
        metadata['release'] = metadata.get('release', 1)
        open(path, 'w').write(json.dumps(metadata))
    # TODO check if all pedalboards in banks database really exist, otherwise remove them from banks
    ensure_index_sync(effect_index, EFFECT_DIR)

    # TEMPORARIO, APENAS NO DESENVOLVIMENTO
    if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL):
        serial = open(DEVICE_SERIAL).read()
        model = re.search('^[A-Z]+').group()
        open(DEVICE_MODEL, 'w').write(model)

    def ping_callback(ok):
        if ok:
            pass
        else:
            # calls ping again every one second
            ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))
    SESSION.ping(ping_callback)
Esempio n. 9
0
    def _process_msg(self, msg):
        from mod.session import SESSION

        try:
            cmd, instance, port, value = msg.replace("\x00", "").split()
            assert cmd == "monitor"
            instance = int(instance)
            value = float(value)
        except (ValueError, AssertionError) as e:
            # TODO: tratar error
            pass
        else:
            if instance == TUNER:
                SESSION.tuner(value)
        self._handle_conn()
Esempio n. 10
0
 def get(self):
     devsInUse, devList = SESSION.web_get_midi_device_list()
     self.write(json.dumps({
         "devsInUse": devsInUse,
         "devList"  : devList
     }))
     self.finish()
Esempio n. 11
0
    def post(self):
        title = self.get_argument('title')
        asNew = bool(int(self.get_argument('asNew')))

        bundlepath = SESSION.web_save_pedalboard(title, asNew)

        self.write({'ok': bundlepath is not None, 'bundlepath': bundlepath})
Esempio n. 12
0
    def index(self):
        context = {}

        with open(DEFAULT_ICON_TEMPLATE, 'r') as fd:
            default_icon_template = tornado.escape.squeeze(fd.read().replace("'", "\\'"))

        with open(DEFAULT_SETTINGS_TEMPLATE, 'r') as fd:
            default_settings_template = tornado.escape.squeeze(fd.read().replace("'", "\\'"))

        context = {
            'default_icon_template': default_icon_template,
            'default_settings_template': default_settings_template,
            'cloud_url': CLOUD_HTTP_ADDRESS,
            'hardware_profile': b64encode(json.dumps(SESSION.get_hardware()).encode("utf-8")),
            'max_screenshot_width': MAX_SCREENSHOT_WIDTH,
            'max_screenshot_height': MAX_SCREENSHOT_HEIGHT,
            'package_server_address': PACKAGE_SERVER_ADDRESS or '',
            'default_package_server_port': DEFAULT_PACKAGE_SERVER_PORT,
            'package_repository': PACKAGE_REPOSITORY,
            'js_custom_channel': 'true' if JS_CUSTOM_CHANNEL else 'false',
            'auto_cloud_backup': 'true' if AUTO_CLOUD_BACKUP else 'false',
            'avatar_url': AVATAR_URL,
            'version': self.get_argument('v'),
            'bundlepath': json.dumps(SESSION.bundlepath),
            'title': json.dumps(SESSION.title),
            'fulltitle': SESSION.title or "Untitled",
            'using_app': json.dumps(APP),
            'using_desktop': json.dumps(DESKTOP),
        }
        return context
Esempio n. 13
0
 def get(self):
     recd = SESSION.web_recording_download()
     data = {
         'ok'   : bool(recd),
         'audio': b64encode(recd).decode("utf-8") if recd else ""
     }
     self.write(data)
Esempio n. 14
0
 def get(self):
     devsInUse, devList, names = SESSION.web_get_midi_device_list()
     self.write({
         "devsInUse": devsInUse,
         "devList"  : devList,
         "names"    : names,
     })
Esempio n. 15
0
    def get(self, action):
        if action == 'start':
            SESSION.web_playing_start(RecordingPlay.stop_callback)
            self.write(True)
            return

        if action == 'wait':
            if RecordingPlay.waiting_request is not None:
                RecordingPlay.stop_callback()
            RecordingPlay.waiting_request = self
            return

        if action == 'stop':
            SESSION.web_playing_stop()
            self.write(True)
            return

        raise web.HTTPError(404)
Esempio n. 16
0
 def get(self, action):
     if action == 'start':
         self.playing = True
         SESSION.start_playing(RecordingPlay.stop_callback)
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(True))
         return self.finish()
     if action == 'wait':
         if RecordingPlay.waiting_request is not None:
             RecordingPlay.stop_callback()
         RecordingPlay.waiting_request = self
         return
     if action == 'stop':
         SESSION.stop_playing()
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(True))
         return self.finish()
     raise web.HTTPError(404)
Esempio n. 17
0
 def get(self, action):
     if action == 'start':
         self.playing = True
         SESSION.start_playing(RecordingPlay.stop_callback)
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(True))
         return self.finish()
     if action == 'wait':
         if RecordingPlay.waiting_request is not None:
             RecordingPlay.stop_callback()
         RecordingPlay.waiting_request = self
         return
     if action == 'stop':
         SESSION.stop_playing()
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(True))
         return self.finish()
     raise web.HTTPError(404)
Esempio n. 18
0
    def post(self):
        bundlepath = self.get_argument("bundlepath")

        try:
            name = get_pedalboard_name(bundlepath)
        except Exception as e:
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps({ 'ok': False, 'error': str(e).split(") - ",1)[-1] }))
            self.finish()
            return

        SESSION.load_pedalboard(bundlepath, name)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({
            'ok':   True,
            'name': name
        }))
        self.finish()
Esempio n. 19
0
    def post(self):
        bundlepath = self.get_argument("bundlepath")

        try:
            name = get_pedalboard_name(bundlepath)
        except Exception as e:
            self.set_header('Content-Type', 'application/json')
            self.write(
                json.dumps({
                    'ok': False,
                    'error': str(e).split(") - ", 1)[-1]
                }))
            self.finish()
            return

        SESSION.load_pedalboard(bundlepath, name)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({'ok': True, 'name': name}))
        self.finish()
Esempio n. 20
0
    def post(self):
        bundlepath = os.path.abspath(self.get_argument("bundlepath"))

        try:
            isDefault = bool(int(self.get_argument("isDefault")))
        except:
            isDefault = False

        if os.path.exists(bundlepath):
            name = SESSION.load_pedalboard(bundlepath, isDefault)
        else:
            name = None

        self.write({'ok': name is not None, 'name': name or ""})
Esempio n. 21
0
    def index(self):
        context = {}

        with open(DEFAULT_ICON_TEMPLATE, 'r') as fd:
            default_icon_template = tornado.escape.squeeze(fd.read().replace(
                "'", "\\'"))

        with open(DEFAULT_SETTINGS_TEMPLATE, 'r') as fd:
            default_settings_template = tornado.escape.squeeze(
                fd.read().replace("'", "\\'"))

        context = {
            'default_icon_template':
            default_icon_template,
            'default_settings_template':
            default_settings_template,
            'cloud_url':
            CLOUD_HTTP_ADDRESS,
            'hardware_profile':
            b64encode(json.dumps(SESSION.get_hardware()).encode("utf-8")),
            'max_screenshot_width':
            MAX_SCREENSHOT_WIDTH,
            'max_screenshot_height':
            MAX_SCREENSHOT_HEIGHT,
            'package_server_address':
            PACKAGE_SERVER_ADDRESS or '',
            'default_package_server_port':
            DEFAULT_PACKAGE_SERVER_PORT,
            'package_repository':
            PACKAGE_REPOSITORY,
            'js_custom_channel':
            'true' if JS_CUSTOM_CHANNEL else 'false',
            'auto_cloud_backup':
            'true' if AUTO_CLOUD_BACKUP else 'false',
            'avatar_url':
            AVATAR_URL,
            'version':
            self.get_argument('v'),
            'bundlepath':
            json.dumps(SESSION.bundlepath),
            'title':
            json.dumps(SESSION.title),
            'fulltitle':
            SESSION.title or "Untitled",
            'using_app':
            json.dumps(APP),
            'using_desktop':
            json.dumps(DESKTOP),
        }
        return context
Esempio n. 22
0
    def post(self):
        title = self.get_argument('title')
        as_new = bool(int(self.get_argument('asNew')))

        try:
            uid = SESSION.save_pedalboard(title, as_new)
        except Pedalboard.ValidationError as e:
            self.write(json.dumps({ 'ok': False, 'error': str(e) }))
            self.finish()
            raise StopIteration

        THUMB_GENERATOR.schedule_thumbnail(uid)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({ 'ok': True, 'uid': uid }, default=json_handler))
        self.finish()
Esempio n. 23
0
    def index(self):
        context = {}

        user_id = safe_json_load(USER_ID_JSON_FILE, dict)
        prefs   = safe_json_load(PREFERENCES_JSON_FILE, dict)

        with open(DEFAULT_ICON_TEMPLATE, 'r') as fh:
            default_icon_template = squeeze(fh.read().replace("'", "\\'"))

        with open(DEFAULT_SETTINGS_TEMPLATE, 'r') as fh:
            default_settings_template = squeeze(fh.read().replace("'", "\\'"))

        pbname = xhtml_escape(SESSION.host.pedalboard_name)
        prname = SESSION.host.pedalpreset_name()

        fullpbname = pbname or "Untitled"
        if prname:
            fullpbname += " - " + prname

        context = {
            'default_icon_template': default_icon_template,
            'default_settings_template': default_settings_template,
            'default_pedalboard': DEFAULT_PEDALBOARD,
            'cloud_url': CLOUD_HTTP_ADDRESS,
            'pedalboards_url': PEDALBOARDS_HTTP_ADDRESS,
            'hardware_profile': b64encode(json.dumps(SESSION.get_hardware_actuators()).encode("utf-8")),
            'version': self.get_argument('v'),
            'lv2_plugin_dir': LV2_PLUGIN_DIR,
            'bundlepath': SESSION.host.pedalboard_path,
            'title':  pbname,
            'size': json.dumps(SESSION.host.pedalboard_size),
            'fulltitle':  fullpbname,
            'titleblend': '' if SESSION.host.pedalboard_name else 'blend',
            'using_app': 'true' if APP else 'false',
            'using_mod': 'true' if DEVICE_KEY else 'false',
            'user_name': xhtml_escape(user_id.get("name", "")),
            'user_email': xhtml_escape(user_id.get("email", "")),
            'favorites': json.dumps(gState.favorites),
            'preferences': json.dumps(prefs),
        }
        return context
Esempio n. 24
0
    def on_message(self, message):
        if message == "pong":
            return

        data = message.split(" ")
        cmd  = data[0]

        if cmd == "param_set":
            port  = data[1]
            value = float(data[2])
            SESSION.ws_parameter_set(port, value, self)

        elif cmd == "plugin_pos":
            inst = data[1]
            x    = float(data[2])
            y    = float(data[3])
            SESSION.ws_plugin_position(inst, x, y)

        elif cmd == "pb_size":
            width  = int(float(data[1]))
            height = int(float(data[2]))
            SESSION.ws_pedalboard_size(width, height)
Esempio n. 25
0
 def on_close(self):
     print("atom websocket close")
     SESSION.websocket_closed(self)
Esempio n. 26
0
def stop():
    tornado.ioloop.IOLoop.instance().stop()
    SESSION.stop_timers()
Esempio n. 27
0
 def get(self):
     SESSION.reset_recording()
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 28
0
 def get(self):
     result = SESSION.stop_recording()
     #result['data'] = b64encode(result.pop('handle').read().encode("utf-8"))
     #open('/tmp/record.json', 'w').write(json.dumps(result, default=json_handler))
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 29
0
 def on_close(self):
     print("atom websocket close")
     SESSION.websocket_closed(self)
Esempio n. 30
0
 def get(self):
     SESSION.reset(self.result)
Esempio n. 31
0
    def post(self):
        title = self.get_argument('title')
        asNew = bool(int(self.get_argument('asNew')))

        titlesym = symbolify(title)

        # Save over existing bundlepath
        if SESSION.bundlepath and os.path.exists(SESSION.bundlepath) and os.path.isdir(SESSION.bundlepath) and not asNew:
            bundlepath = SESSION.bundlepath

        # Save new
        else:
            lv2path = os.path.expanduser("~/.lv2/") # FIXME: cross-platform
            trypath = os.path.join(lv2path, "%s.pedalboard" % titlesym)

            # if trypath already exists, generate a random bundlepath based on title
            if os.path.exists(trypath):
                from random import randint

                while True:
                    trypath = os.path.join(lv2path, "%s-%i.pedalboard" % (titlesym, randint(1,99999)))
                    if os.path.exists(trypath):
                        continue
                    bundlepath = trypath
                    break

            # trypath doesn't exist yet, use it
            else:
                bundlepath = trypath

                # just in case..
                if not os.path.exists(lv2path):
                    os.mkdir(lv2path)

            os.mkdir(bundlepath)

        # callback for when ingen is done doing its business
        def callback(ok):
            if not ok:
                self.write(json.dumps({ 'ok': False, 'error': "Failed" })) # TODO more descriptive error?
                self.finish()
                return

            # Create a custom manifest.ttl, not created by ingen because we want *.pedalboard extension
            with open(os.path.join(bundlepath, "manifest.ttl"), 'w') as fd:
                fd.write('''\
@prefix ingen: <http://drobilla.net/ns/ingen#> .
@prefix lv2:   <http://lv2plug.in/ns/lv2core#> .
@prefix pedal: <http://portalmod.com/ns/modpedal#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<%s.ttl>
    lv2:prototype ingen:GraphPrototype ;
    a lv2:Plugin ,
        ingen:Graph ,
        pedal:Pedalboard ;
    rdfs:seeAlso <%s.ttl> .
''' % (titlesym, titlesym))

            # All ok!
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps({ 'ok': True, 'bundlepath': bundlepath }, default=json_handler))
            self.finish()

        # Ask ingen to save
        SESSION.save_pedalboard(bundlepath, title, callback)
Esempio n. 32
0
 def get(self):
     SESSION.web_recording_stop()
     self.write(True)
Esempio n. 33
0
 def get(self):
     result = SESSION.stop_recording()
     #result['data'] = b64encode(result.pop('handle').read().encode("utf-8"))
     #open('/tmp/record.json', 'w').write(json.dumps(result, default=json_handler))
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 34
0
 def get(self):
     SESSION.reset_recording()
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 35
0
def start():
    SESSION.start_timers()
    tornado.ioloop.IOLoop.instance().start()
Esempio n. 36
0
def stop():
    tornado.ioloop.IOLoop.instance().stop()
    SESSION.stop_timers()
Esempio n. 37
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_HostWindow()
        self.ui.setupUi(self)

        # ----------------------------------------------------------------------------------------------------
        # Internal stuff

        # Current mod-ui title
        #self.fCurrentBundle = ""
        self.fCurrentTitle  = ""

        # Next bundle to load (done by startup arguments)
        self.fNextBundle = ""

        # first attempt of auto-start backend doesn't show an error
        self.fFirstBackendInit = True

        # need to call session reconnect after connecting the 1st time
        self.fNeedsSessionReconnect = False

        # Qt idle timer
        self.fIdleTimerId = 0

        # Qt web frame, used for evaluating javascript
        self.fWebFrame = None

        # to be filled with key-value pairs of current settings
        self.fSavedSettings = {}

        # List of pedalboards
        self.fPedalboards = get_all_pedalboards()

        # List of current-pedalboard presets
        self.fPresetMenuList = []

        # Process that runs the backend
        self.fProccessBackend = QProcess(self)
        self.fProccessBackend.setProcessChannelMode(QProcess.MergedChannels)
        self.fProccessBackend.setReadChannel(QProcess.StandardOutput)
        self.fStoppingBackend = False

        # Thread for managing the webserver
        self.fWebServerThread = WebServerThread(self)

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI

        self.ui.webview = QWebView(self.ui.swp_webview)
        self.ui.webview.setMinimumWidth(980)
        self.ui.swp_webview.layout().addWidget(self.ui.webview)

        self.ui.webpage = HostWebPage(self)
        self.ui.webpage.setViewportSize(QSize(980, 600))
        self.ui.webview.setPage(self.ui.webpage)

        self.ui.webinspector = QWebInspector(None)
        self.ui.webinspector.resize(800, 600)
        self.ui.webinspector.setPage(self.ui.webpage)
        self.ui.webinspector.setVisible(False)

        self.ui.act_file_connect.setEnabled(False)
        self.ui.act_file_connect.setVisible(False)
        self.ui.act_file_disconnect.setEnabled(False)
        self.ui.act_file_disconnect.setVisible(False)

        self.ui.label_app.setText("MOD Application v%s" % config["version"])

        # disable file menu
        self.ui.act_file_refresh.setEnabled(False)
        self.ui.act_file_inspect.setEnabled(False)

        # disable pedalboard menu
        self.ui.act_pedalboard_new.setEnabled(False)
        self.ui.act_pedalboard_open.setEnabled(False)
        self.ui.act_pedalboard_save.setEnabled(False)
        self.ui.act_pedalboard_save_as.setEnabled(False)
        self.ui.act_pedalboard_share.setEnabled(False)
        self.ui.menu_Pedalboard.setEnabled(False)

        # disable presets menu
        self.ui.act_presets_new.setEnabled(False)
        self.ui.act_presets_save.setEnabled(False)
        self.ui.act_presets_save_as.setEnabled(False)
        self.ui.menu_Presets.setEnabled(False)

        # initial stopped state
        self.slot_backendFinished(-1, -1)

        # Qt needs this so it properly creates & resizes the webview
        self.ui.stackedwidget.setCurrentIndex(1)
        self.ui.stackedwidget.setCurrentIndex(0)

        # FIXME
        #self.ui.act_backend_stop.setVisible(False)
        #self.ui.act_backend_restart.setVisible(False)

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI (special stuff for Mac OS)

        if MACOS:
            self.ui.act_file_quit.setMenuRole(QAction.QuitRole)
            self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole)
            self.ui.act_help_about.setMenuRole(QAction.AboutRole)
            #self.ui.menu_Settings.setTitle("Panels")
            #self.ui.menu_Help.hide()

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI (special stuff for Live-MOD ISO)

        if USING_LIVE_ISO:
            self.ui.menubar.hide()
            self.ui.b_start.hide()
            self.ui.b_configure.hide()
            self.ui.b_about.hide()

        # ----------------------------------------------------------------------------------------------------
        # Load Settings

        self.loadSettings(True)

        # ----------------------------------------------------------------------------------------------------
        # Connect actions to functions

        self.SIGUSR1.connect(self.slot_handleSIGUSR1)
        self.SIGTERM.connect(self.slot_handleSIGTERM)

        self.fProccessBackend.error.connect(self.slot_backendError)
        self.fProccessBackend.started.connect(self.slot_backendStarted)
        self.fProccessBackend.finished.connect(self.slot_backendFinished)
        self.fProccessBackend.readyRead.connect(self.slot_backendRead)

        self.fWebServerThread.running.connect(self.slot_webServerRunning)
        self.fWebServerThread.finished.connect(self.slot_webServerFinished)

        self.ui.menu_Pedalboard.aboutToShow.connect(self.slot_pedalboardCheckOnline)

        self.ui.act_file_refresh.triggered.connect(self.slot_fileRefresh)
        self.ui.act_file_inspect.triggered.connect(self.slot_fileInspect)

        self.ui.act_backend_information.triggered.connect(self.slot_backendInformation)
        self.ui.act_backend_start.triggered.connect(self.slot_backendStart)
        self.ui.act_backend_stop.triggered.connect(self.slot_backendStop)
        self.ui.act_backend_restart.triggered.connect(self.slot_backendRestart)

        self.ui.act_pedalboard_new.triggered.connect(self.slot_pedalboardNew)
        self.ui.act_pedalboard_open.triggered.connect(self.slot_pedalboardOpen)
        self.ui.act_pedalboard_save.triggered.connect(self.slot_pedalboardSave)
        self.ui.act_pedalboard_save_as.triggered.connect(self.slot_pedalboardSaveAs)
        self.ui.act_pedalboard_share.triggered.connect(self.slot_pedalboardShare)

        self.ui.act_settings_configure.triggered.connect(self.slot_configure)

        self.ui.act_help_about.triggered.connect(self.slot_about)
        self.ui.act_help_project.triggered.connect(self.slot_showProject)
        self.ui.act_help_website.triggered.connect(self.slot_showWebsite)

        self.ui.b_start.clicked.connect(self.slot_backendStart)
        self.ui.b_configure.clicked.connect(self.slot_configure)
        self.ui.b_about.clicked.connect(self.slot_about)

        # force our custom refresh
        webReloadAction = self.ui.webpage.action(QWebPage.Reload)
        webReloadAction.triggered.disconnect()
        webReloadAction.triggered.connect(self.slot_fileRefresh)

        # ----------------------------------------------------------------------------------------------------
        # Final setup

        self.setProperWindowTitle()
        SESSION.setupApp(self._pedal_changed_callback)

        if not "--no-autostart" in sys.argv:
            QTimer.singleShot(0, self.slot_backendStart)

        QTimer.singleShot(1, self.fixWebViewSize)
Esempio n. 38
0
    def _process_msg(self, msg):
        from mod.session import SESSION

        try:
            cmd, instance, port, value = msg.replace("\x00", "").split()
            assert cmd == "monitor"
            instance = int(instance)
            value = float(value)
        except (ValueError, AssertionError) as e:
            # TODO: tratar error
            pass
        else:
            if instance == CLIPMETER_IN:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(0, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(1, value)

            elif instance == CLIPMETER_OUT:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(2, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(3, value)

            elif instance == PEAKMETER_IN:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_inl_value = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_inr_value = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_inl_peak = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_inr_peak = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

            elif instance == PEAKMETER_OUT:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_outl_value = value
                    SESSION.peakmeter(2, self.pkm_outl_value,
                                      self.pkm_outl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_outr_value = value
                    SESSION.peakmeter(3, self.pkm_outr_value,
                                      self.pkm_outr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_outl_peak = value
                    SESSION.peakmeter(2, self.pkm_outl_value,
                                      self.pkm_outl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_outr_peak = value
                    SESSION.peakmeter(3, self.pkm_outr_value,
                                      self.pkm_outr_peak)

            elif instance == TUNER:
                SESSION.tuner(value)
        self._handle_conn()
Esempio n. 39
0
 def open(self):
     SESSION.websocket_opened(self)
Esempio n. 40
0
 def get(self):
     SESSION.web_recording_delete()
     self.write(True)
Esempio n. 41
0
 def get(self):
     width = int(self.get_argument('width'))
     height = int(self.get_argument('height'))
     SESSION.pedalboard_size(width, height)
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 42
0
 def post(self):
     devs = json.loads(self.request.body.decode("utf-8", errors="ignore"))
     SESSION.web_set_midi_devices(devs)
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 43
0
 def get(self):
     SESSION.end_session(self.result)
Esempio n. 44
0
 def get(self):
     devsInUse, devList = SESSION.web_get_midi_device_list()
     self.write(json.dumps({"devsInUse": devsInUse, "devList": devList}))
     self.finish()
Esempio n. 45
0
 def post(self):
     devs = json.loads(self.request.body.decode("utf-8", errors="ignore"))
     SESSION.web_set_midi_devices(devs)
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
Esempio n. 46
0
 def get(self, path):
     super(EditionLoader, self).get(path)
     SESSION.start_session()
Esempio n. 47
0
    def _process_msg(self, msg):
        from mod.session import SESSION

        try:
            cmd, instance, port, value =  msg.replace("\x00", "").split()
            assert cmd == "monitor"
            instance = int(instance)
            value = float(value)
        except (ValueError, AssertionError) as e:
            # TODO: tratar error
            pass
        else:
            if instance == CLIPMETER_IN:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(0, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(1, value)

            elif instance == CLIPMETER_OUT:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(2, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(3, value)

            elif instance == PEAKMETER_IN:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_inl_value = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_inr_value = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_inl_peak = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_inr_peak = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

            elif instance == PEAKMETER_OUT:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_outl_value = value
                    SESSION.peakmeter(2, self.pkm_outl_value, self.pkm_outl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_outr_value = value
                    SESSION.peakmeter(3, self.pkm_outr_value, self.pkm_outr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_outl_peak = value
                    SESSION.peakmeter(2, self.pkm_outl_value, self.pkm_outl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_outr_peak = value
                    SESSION.peakmeter(3, self.pkm_outr_value, self.pkm_outr_peak)

            elif instance == TUNER:
                SESSION.tuner(value)
        self._handle_conn()
Esempio n. 48
0
 def get(self):
     hardware = SESSION.get_hardware()
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(hardware))
Esempio n. 49
0
def start():
    SESSION.start_timers()
    tornado.ioloop.IOLoop.instance().start()
Esempio n. 50
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_HostWindow()
        self.ui.setupUi(self)

        # ----------------------------------------------------------------------------------------------------
        # Internal stuff

        # Current mod-ui title
        #self.fCurrentBundle = ""
        self.fCurrentTitle = ""

        # Next bundle to load (done by startup arguments)
        self.fNextBundle = ""

        # first attempt of auto-start backend doesn't show an error
        self.fFirstBackendInit = True

        # need to call session reconnect after connecting the 1st time
        self.fNeedsSessionReconnect = False

        # Qt idle timer
        self.fIdleTimerId = 0

        # Qt web frame, used for evaluating javascript
        self.fWebFrame = None

        # to be filled with key-value pairs of current settings
        self.fSavedSettings = {}

        # List of pedalboards
        self.fPedalboards = get_all_pedalboards()

        # List of current-pedalboard presets
        self.fPresetMenuList = []

        # Process that runs the backend
        self.fProccessBackend = QProcess(self)
        self.fProccessBackend.setProcessChannelMode(QProcess.MergedChannels)
        self.fProccessBackend.setReadChannel(QProcess.StandardOutput)
        self.fStoppingBackend = False

        # Thread for managing the webserver
        self.fWebServerThread = WebServerThread(self)

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI

        self.ui.webview = QWebView(self.ui.swp_webview)
        self.ui.webview.setMinimumWidth(980)
        self.ui.swp_webview.layout().addWidget(self.ui.webview)

        self.ui.webpage = HostWebPage(self)
        self.ui.webpage.setViewportSize(QSize(980, 600))
        self.ui.webview.setPage(self.ui.webpage)

        self.ui.webinspector = QWebInspector(None)
        self.ui.webinspector.resize(800, 600)
        self.ui.webinspector.setPage(self.ui.webpage)
        self.ui.webinspector.setVisible(False)

        self.ui.act_file_connect.setEnabled(False)
        self.ui.act_file_connect.setVisible(False)
        self.ui.act_file_disconnect.setEnabled(False)
        self.ui.act_file_disconnect.setVisible(False)

        self.ui.label_app.setText("MOD Application v%s" % config["version"])

        # disable file menu
        self.ui.act_file_refresh.setEnabled(False)
        self.ui.act_file_inspect.setEnabled(False)

        # disable pedalboard menu
        self.ui.act_pedalboard_new.setEnabled(False)
        self.ui.act_pedalboard_open.setEnabled(False)
        self.ui.act_pedalboard_save.setEnabled(False)
        self.ui.act_pedalboard_save_as.setEnabled(False)
        self.ui.act_pedalboard_share.setEnabled(False)
        self.ui.menu_Pedalboard.setEnabled(False)

        # disable presets menu
        self.ui.act_presets_new.setEnabled(False)
        self.ui.act_presets_save.setEnabled(False)
        self.ui.act_presets_save_as.setEnabled(False)
        self.ui.menu_Presets.setEnabled(False)

        # initial stopped state
        self.slot_backendFinished(-1, -1)

        # Qt needs this so it properly creates & resizes the webview
        self.ui.stackedwidget.setCurrentIndex(1)
        self.ui.stackedwidget.setCurrentIndex(0)

        # FIXME
        #self.ui.act_backend_stop.setVisible(False)
        #self.ui.act_backend_restart.setVisible(False)

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI (special stuff for Mac OS)

        if MACOS:
            self.ui.act_file_quit.setMenuRole(QAction.QuitRole)
            self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole)
            self.ui.act_help_about.setMenuRole(QAction.AboutRole)
            #self.ui.menu_Settings.setTitle("Panels")
            #self.ui.menu_Help.hide()

        # ----------------------------------------------------------------------------------------------------
        # Load Settings

        self.loadSettings(True)

        # ----------------------------------------------------------------------------------------------------
        # Connect actions to functions

        self.SIGUSR1.connect(self.slot_handleSIGUSR1)
        self.SIGTERM.connect(self.slot_handleSIGTERM)

        self.fProccessBackend.error.connect(self.slot_backendError)
        self.fProccessBackend.started.connect(self.slot_backendStarted)
        self.fProccessBackend.finished.connect(self.slot_backendFinished)
        self.fProccessBackend.readyRead.connect(self.slot_backendRead)

        self.fWebServerThread.running.connect(self.slot_webServerRunning)
        self.fWebServerThread.finished.connect(self.slot_webServerFinished)

        self.ui.act_file_refresh.triggered.connect(self.slot_fileRefresh)
        self.ui.act_file_inspect.triggered.connect(self.slot_fileInspect)

        self.ui.act_settings_configure.triggered.connect(self.slot_configure)

        self.ui.act_help_about.triggered.connect(self.slot_about)
        self.ui.act_help_project.triggered.connect(self.slot_showProject)
        self.ui.act_help_website.triggered.connect(self.slot_showWebsite)

        self.ui.b_start.clicked.connect(self.slot_backendStart)
        self.ui.b_configure.clicked.connect(self.slot_configure)
        self.ui.b_about.clicked.connect(self.slot_about)

        # force our custom refresh
        webReloadAction = self.ui.webpage.action(QWebPage.Reload)
        webReloadAction.triggered.disconnect()
        webReloadAction.triggered.connect(self.slot_fileRefresh)

        # ----------------------------------------------------------------------------------------------------
        # Final setup

        self.setProperWindowTitle()
        SESSION.setupApp(self._pedal_changed_callback)

        if not "--no-autostart" in sys.argv:
            QTimer.singleShot(0, self.slot_backendStart)

        QTimer.singleShot(1, self.fixWebViewSize)
Esempio n. 51
0
 def open(self):
     print("atom websocket open")
     SESSION.websocket_opened(self)
Esempio n. 52
0
 def ping_callback(ok):
     if ok:
         pass
     else:
         # calls ping again every one second
         ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))
Esempio n. 53
0
 def get(self):
     hardware = SESSION.get_hardware()
     self.write(hardware)
Esempio n. 54
0
 def open(self):
     print("atom websocket open")
     SESSION.websocket_opened(self)
Esempio n. 55
0
 def get(self):
     hardware = SESSION.get_hardware()
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(hardware))
Esempio n. 56
0
 def post(self):
     devs = json.loads(self.request.body.decode("utf-8", errors="ignore"))
     SESSION.web_set_midi_devices(devs)
     self.write(True)
Esempio n. 57
0
 def get(self, path):
     super(EditionLoader, self).get(path)
     SESSION.start_session()
Esempio n. 58
0
    def _process_msg(self, msg):
        from mod.session import SESSION

        try:
            cmd, instance, port, value =  msg.replace("\x00", "").split()
            assert cmd == "monitor"
            instance = int(instance)
            value = float(value)
        except (ValueError, AssertionError), e:
            # TODO: tratar error
            pass
        else:
            if instance == CLIPMETER_IN:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(0, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(1, value)

            elif instance == CLIPMETER_OUT:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(2, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(3, value)

            elif instance == PEAKMETER_IN:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_inl_value = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_inr_value = value