Skip to content

Window

Window

A class representing a windowing scheme used in signal segmentation.

Attributes:

Name Type Description
hop_size int

The step size for shifting the window in the segmentation process.

analysis_window NDArray[T]

The window function used during the analysis phase.

synthesis_window NDArray[T]

The window function used during the synthesis phase.

Source code in src/libsegmenter/Window.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Window:
    """
    A class representing a windowing scheme used in signal segmentation.

    Attributes:
        hop_size (int): The step size for shifting the window in the segmentation
            process.
        analysis_window (NDArray[T]): The window function used during the analysis
            phase.
        synthesis_window (NDArray[T]): The window function used during the synthesis
            phase.

    """

    def __init__(
        self,
        hop_size: int,
        analysis_window: NDArray[T],
        synthesis_window: NDArray[T] | None,
    ) -> None:
        """
        Initializes the Window instance with the specified hop size and windows.

        Args:
            hop_size (int): The step size for shifting the window in the segmentation
                process.
            analysis_window (NDArray[T]): The window function applied during analysis.
            synthesis_window (NDArray[T] | None): The window function applied during
                synthesis.

        """
        if hop_size <= 0 or hop_size > analysis_window.shape[-1]:
            raise ValueError(
                "Hop size argument must be between 1 and the length of the window. "
                + "Received hop size = "
                + f"({hop_size}) while the window size is "
                + f"({analysis_window.shape[-1]})."
            )
        if synthesis_window is not None:
            if analysis_window.shape[-1] != synthesis_window.shape[-1]:
                raise ValueError(
                    "The analysis and synthesis windows must be of equal lengths. "
                    + "Received analysis window length = "
                    + f"({analysis_window.shape[-1]}) and synthesis window length = "
                    + f"({synthesis_window.shape[-1]})."
                )
        self.hop_size = hop_size
        self.analysis_window = analysis_window
        self.synthesis_window = synthesis_window

__init__(hop_size, analysis_window, synthesis_window)

Initializes the Window instance with the specified hop size and windows.

Parameters:

Name Type Description Default
hop_size int

The step size for shifting the window in the segmentation process.

required
analysis_window NDArray[T]

The window function applied during analysis.

required
synthesis_window NDArray[T] | None

The window function applied during synthesis.

required
Source code in src/libsegmenter/Window.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def __init__(
    self,
    hop_size: int,
    analysis_window: NDArray[T],
    synthesis_window: NDArray[T] | None,
) -> None:
    """
    Initializes the Window instance with the specified hop size and windows.

    Args:
        hop_size (int): The step size for shifting the window in the segmentation
            process.
        analysis_window (NDArray[T]): The window function applied during analysis.
        synthesis_window (NDArray[T] | None): The window function applied during
            synthesis.

    """
    if hop_size <= 0 or hop_size > analysis_window.shape[-1]:
        raise ValueError(
            "Hop size argument must be between 1 and the length of the window. "
            + "Received hop size = "
            + f"({hop_size}) while the window size is "
            + f"({analysis_window.shape[-1]})."
        )
    if synthesis_window is not None:
        if analysis_window.shape[-1] != synthesis_window.shape[-1]:
            raise ValueError(
                "The analysis and synthesis windows must be of equal lengths. "
                + "Received analysis window length = "
                + f"({analysis_window.shape[-1]}) and synthesis window length = "
                + f"({synthesis_window.shape[-1]})."
            )
    self.hop_size = hop_size
    self.analysis_window = analysis_window
    self.synthesis_window = synthesis_window