Exemplo n.º 1
0
    def add_region(self, start, end, name="", color=0):
        """
        Create new region and return its index.

        Parameters
        ----------
        start : float
            Region start in seconds.
        end : float
            Region end in seconds.
        name : str, optional
            Region name.
        color : int or tuple of int, optional
            Region color. Integers correspond to REAPER native colors.
            Tuple must be RGB triplets of integers between 0 and 255.

        Returns
        -------
        region : reapy.Region
            New region.
        """
        if isinstance(color, tuple):
            color = reapy.rgb_to_native(color) | 0x1000000
        region_id = RPR.AddProjectMarker2(self.id, True, start, end, name, -1,
                                          color)
        region = reapy.Region(self, region_id)
        return region
Exemplo n.º 2
0
    def regions(self):
        """
        List of project regions.

        :type: list of reapy.Region
        """
        ids = [
            RPR.EnumProjectMarkers2(self.id, i, 0, 0, 0, 0, 0)
            for i in range(self.n_regions + self.n_markers)
        ]
        return [reapy.Region(self, i[0]) for i in ids if i[3]]