Пример #1
0
def update(_list, conn_text: TextInput, instance) -> None:
    # ping(conn_text.text)
    # is_connected(conn_text.text, 2307)
    try:
        conn = rpr.connect(conn_text.text)
        with rpr.inside_reaper():
            print(f'connected to {conn_text.text}')
    except (rpr.errors.DisabledDistAPIError, AttributeError):
        print('cannot connect to "{}"'.format(conn_text.text))
        # conn_text.background_color = (1, 0, 0)
        return
    # else:
    #     conn_text.background_color = (1, 1, 1)
    Config.set(SECTION, 'IP', conn_text.text)
    Config.write()
    print(f'SECTION, "IP" to {conn_text.text}')

    with rpr.inside_reaper():
        items_list = get_items_list()

        pr = rpr.Project()
        ts = pr.time_selection
        ts.start = 0
        ts.end = pr.length
        rpr.perform_action(40420)
        ts.end = 0

        for item in items_list:
            item_ = item.item
            pr.add_marker(item_.position + item_.length - .1, name='!1016')

        print(items_list)
        update_list(_list, items_list)
Пример #2
0
    def sync_recarm(self) -> None:
        """Synchronize recarm state of all childs with target childs.

        Raises
        ------
        SessionError
            If no childs matched to slave.
        """
        if self.target is None:
            raise SessionError(f'no target for track {self.name} ({self})')
        if not self._childs_matched_primary:
            raise SessionError(f'no matched childs for {self.name} ({self})')
        childs = self._return_matched_childs(TrackChildsSet.both)
        t_host = self.s_project.last_ip
        Targets = te.TypedDict('Targets', {'target': Track, 'recarm': bool})

        with rpr.inside_reaper():
            targets: ty.Dict[Track.ID, Targets] = {}
            for child in childs.values():
                recarm = child.recarm
                assert child.target, f'no target for child: {child}'
                target = child.target
                if target.id not in targets:
                    targets[target.id] = {'target': target, 'recarm': recarm}
                elif recarm is True:
                    targets[target.id]['recarm'] = True
        with rpr.connect(t_host):
            with rpr.inside_reaper():
                # with self.target.make_current_project():
                for t_dict in targets.values():
                    target = t_dict['target']
                    recarm = t_dict['recarm']
                    target.recarm = recarm
Пример #3
0
    def match_childs(
        self,
        childs_set: TrackChildsSet = TrackChildsSet.both
    ) -> ty.Dict[Track.ID, Track]:
        """Flat collection of childs, matched to the slave tracks.

        Returns
        -------
        ty.Dict[Track.ID, Track]

        Raises
        ------
        SessionError
            If no target set for the Track.
        """
        if self._childs_matched_primary:
            return self._return_matched_childs(childs_set)
        if not self.target:
            raise SessionError(f'track {self} has no target')
        s_ch_tree = self.get_childs_tree()
        # with self.target.make_current_project():
        with rpr.connect(self.target.project.last_ip):
            t_ch_tree = self.target.get_childs_tree()
        self._childs_matched_primary, self._childs_matched_secondary = \
            Child.match(
                s_ch_tree, t_ch_tree, self.target
            )
        return self._return_matched_childs(childs_set)
Пример #4
0
    def connect(self):
        if not self.connected_once:
            log.info("Connecting to reaper (address=%s)..." %
                     settings.REAPER_IP)
            reapy.connect(settings.REAPER_IP)
            self.connected_once = True
            Thread(target=self.periodic_recorder_update, daemon=True).start()
        else:
            log.info("Reconnecting to reaper...")
            reapy.reconnect()

        self.is_connected = True
        log.info("Connected to reaper!")

        if self.on_connect:
            self.on_connect()
Пример #5
0
def get_host_jack_ports(
    host: ty.Optional[str] = None
) -> ty.Tuple[ty.List[_JMidiPort], ty.List[_JMidiPort]]:
    """Return all Jack midi ports of Reaper on the specified host.

    Note
    ----
    reascript 'Levitanus: (session_management) get_system_jack_ports'
    has to be registered in action editor.

    Parameters
    ----------
    host : ty.Optional[str], optional
        'localhost' or IPV4 address

    No Longer Returned
    ------------------
    jack_in_ports: _JMidiPort
    jack_out_ports _JMidiPort

    """
    if host == 'localhost':
        host = None
    with rpr.connect(host):
        with rpr.inside_reaper():
            a_id: int = RPR.NamedCommandLookup(
                '_RSc3a0868bee74abaf333ac661af9a4a27257c37c1')
            rpr.perform_action(a_id)
            ports = prs.loads('slave_ports')
            # print(ports)
            return ports
Пример #6
0
def get_host_midi_ports(
    host: ty.Optional[str] = None
) -> ty.Tuple[ty.List[_RMidiPort], ty.List[_RMidiPort]]:
    """Get all MIDI devices of the particular host.

    Parameters
    ----------
    host : ty.Optional[str], optional
        'localhost' or IPV4 address

    No Longer Returned
    ------------------
    jack_in_ports: _JMidiPort
    jack_out_ports _JMidiPort

    """
    if host == 'localhost':
        host = None

    ins, outs = [], []
    with rpr.connect(host):
        with rpr.inside_reaper():
            for i, port in enumerate(rpr.midi.get_input_names()):
                ins.append(_RMidiPort(idx=i, name=port))
            for i, port in enumerate(rpr.midi.get_output_names()):
                outs.append(_RMidiPort(idx=i, name=port))
    return ins, outs
Пример #7
0
 def __enter__(self) -> Track:
     pr = self.track.s_project
     self.connect = rpr.connect(pr.last_ip)
     self.connect.__enter__()
     self.ir = rpr.inside_reaper()
     self.ir.__enter__()
     self.curr_proj = pr.make_current_project()
     self.curr_proj.__enter__()
     return self.track
Пример #8
0
def connect_by_task(
        task: ty.Tuple[ty.List[_RTrackPort], ty.List[_RTrackPort]]) -> None:
    """Make a final connection of all tracks.

    Parameters
    ----------
    task : ty.Tuple[ty.List[_RTrackPort], ty.List[_RTrackPort]]
        see 'get_connections_task(hosts)'

    """
    for i_port in task[0]:
        with rpr.connect(i_port['host']):
            with i_port['track'].project.make_current_project():
                set_track_midi_in(i_port['track'], i_port['port']['idx'])
    for o_port in task[1]:
        with rpr.connect(o_port['host']):
            with o_port['track'].project.make_current_project():
                set_track_midi_out(o_port['track'], o_port['port']['idx'])
Пример #9
0
 def hosts_check(self) -> None:
     availble = set()
     for host in self._hosts:
         try:
             with rpr.connect(host.ip):
                 availble.add(host)
         except rpr.errors.DisabledDistAPIError:
             continue
     self._hosts &= availble
Пример #10
0
    if response == 0:
        print(hostname, 'is up!')
    else:
        print(hostname, 'is down!')


if __name__ == '__main__':
    is_connected('8.8.8.8')
    is_connected('ya.ru')
    Config.adddefaultsection(SECTION)
    Config.setdefault(SECTION, 'IP', "192.168.0.1")
    grid = GridLayout(cols=1, spacing=20)

    conn_text = TextInput(text=Config.get(SECTION, 'IP'))
    try:
        conn = rpr.connect(conn_text.text)
        with rpr.inside_reaper():
            print(f'connected to {conn_text.text}')
    except (rpr.errors.DisabledDistAPIError, AttributeError):
        print('cannot connect to "{}"'.format(conn_text.text))
    itemlist = get_items_list()
    print(*(item.name for item in itemlist), sep=' | ')
    scroll, layout = get_layouts()
    update_list(layout, itemlist)

    connection_grid = GridLayout(cols=2, spacing=10, size_hint_y=.5)
    upd_btn = Button(text='update')
    upd_btn.bind(on_press=lambda instance: update(layout, conn_text, instance))
    connection_grid.add_widget(conn_text)
    connection_grid.add_widget(upd_btn)
    grid.add_widget(connection_grid)
Пример #11
0
 def __enter__(self) -> Host:
     self._connect = rpr.connect(self.ip)
     self._connect.__enter__()
     self._ir = rpr.inside_reaper()
     self._ir.__enter__()
     return self
Пример #12
0
 def __init__(self, ip: HostIP) -> None:
     with rpr.connect(ip):
         self.ip = ip
Пример #13
0
 def host_add(self, host: Host) -> None:
     with rpr.connect(host.ip):
         self._hosts.add(host)