Esempio n. 1
0
def enable_dist_api():
    """Enable distant API.

    .. deprecated:: 0.8.0
          ``enable_dist_api`` will be removed in reapy 1.0.0.
          Use :func:`reapy.config.configure_reaper` that works
          even from outside REAPER.

    Create a Web interface and add the ReaScript
    ``reapy.reascripts.activate_reapy_server`` to the Actions list.
    """
    msg = ("Function enable_dist_api is deprecated since 0.8.0. "
           "Use reapy.config.configure_reaper instead.")
    warnings.warn(FutureWarning(msg))
    if not reapy.is_inside_reaper():
        raise OutsideREAPERError
    create_new_web_interface(WEB_INTERFACE_PORT)
    reascript_path = get_activate_reapy_server_path()
    action_id = reapy.add_reascript(reascript_path)
    command_name = json.dumps(reapy.get_command_name(action_id))
    section, key, value = "reapy", "activate_reapy_server", command_name
    reapy.set_ext_state(section, key, value, persist=True)
    message = (
        "reapy successfully enabled!\n\nPlease restart REAPER.\n\nYou will "
        "then be able to import reapy from the outside.")
    reapy.show_message_box(message)
Esempio n. 2
0
def cnoose_ip() -> ty.Optional[str]:
    """Ask user to choose IP for slave server."""
    hard = ty.cast(ty.List[str], nip.interfaces())  # type:ignore
    log(hard)
    log([nip.ifaddresses(iface) for iface in hard])  # type:ignore
    addresses = ty.cast(
        ty.List[str],
        [
            nip.ifaddresses(iface)[nip.AF_INET][0]['addr']  # type:ignore
            for iface in hard
        ])
    log(*addresses)
    rpr.delete_ext_state(EXT_SECTION, ADDRESS_KEY_SLAVE, persist=True)
    for addr in addresses:
        response = rpr.show_message_box(
            text=f"""slave server can listen of dollowing ips:
            {addresses}
            Do you want to use {addr}?
            (other will be prompted if you refuse)""",
            title="choose slave IP",
            type="yes-no")
        if response == 'yes':
            rpr.set_ext_state(EXT_SECTION, ADDRESS_KEY_SLAVE, addr)
            return rpr.get_ext_state(EXT_SECTION, ADDRESS_KEY_SLAVE)

    rpr.show_message_box(text='no IP set', title='status', type="ok")
    return None
Esempio n. 3
0
def enable_dist_api():
    """
    Enable distant API.

    Create a Web interface and add the ReaScript
    ``reapy.reascripts.activate_reapy_server`` to the Actions list.
    """
    if not reapy.is_inside_reaper():
        raise OutsideREAPERError
    create_new_web_interface(WEB_INTERFACE_PORT)
    reascript_path = get_activate_reapy_server_path()
    action_id = reapy.add_reascript(reascript_path)
    command_name = json.dumps(reapy.get_command_name(action_id))
    section, key, value = "reapy", "activate_reapy_server", command_name
    reapy.set_ext_state(section, key, value, persist=True)
    message = (
        "reapy successfully enabled!\n\nPlease restart REAPER.\n\nYou will "
        "then be able to import reapy from the outside.")
    reapy.show_message_box(message)
Esempio n. 4
0
    def get_midi_from_track(
            self,
            track: rpr.Track,
            project_idx: ty.Optional[int] = None) -> ty.List[MidiBuf]:
        pr = track.project

        project_idx = self._get_project_idx(pr, project_idx)
        for idx, tr in enumerate(pr.tracks):
            if tr.id == track.id:
                track_idx = idx

        rpr.set_ext_state(EXT_SECTION, self.key_proj_idx, str(project_idx))
        rpr.set_ext_state(EXT_SECTION, self.key_track_idx, str(track_idx))
        # fx = add_jsfx_to_track(track)
        fx = track.fxs[self.fx_name]
        rpr.set_ext_state(EXT_SECTION, self.key_fx_idx, str(fx.index))

        self._get_from_lua()
        raw_midi = rpr.get_ext_state(EXT_SECTION, self.key_result)
        if raw_midi == '':
            raise RuntimeError('no midi_data got from the track')
        return self._deserialize_buffer(raw_midi)
Esempio n. 5
0
def get_new_reapy_server():
    server_port = reapy.config.REAPY_SERVER_PORT
    reapy.set_ext_state("reapy", "server_port", server_port)
    server = Server(server_port)
    return server
Esempio n. 6
0
def dumps(key: str, data: object, persist: bool = False) -> None:
    dump = pickle.dumps(data)
    state = codecs.encode(dump, 'base64').decode()
    rpr.set_ext_state(SECTION, key, state, persist=persist)