msaf/input_output.py
def align_times(times, frames):
    """Aligns the times to the closest frame times (e.g. beats).

    Parameters
    ----------
    times: np.ndarray
        Times in seconds to be aligned.
    frames: np.ndarray
        Frame times in seconds.

    Returns
    -------
    aligned_times: np.ndarray
        Aligned times.
    """
    dist = np.minimum.outer(times, frames)
    bound_frames = np.argmax(np.maximum(0, dist), axis=1)
    aligned_times = np.unique(bound_frames)
    return aligned_times
def align_times(times, frames):
    """Aligns the times to the closest frame times (e.g. beats).

    Parameters
    ----------
    times: np.ndarray
        Times in seconds to be aligned.
    frames: np.ndarray
        Frame times in seconds.

    Returns
    -------
    aligned_times: np.ndarray
        Aligned times.
    """
    dist = np.minimum.outer(times, frames)
    bound_frames = np.argmax(np.maximum(0, dist), axis=1)
    aligned_times = np.unique(bound_frames)
    return aligned_times
Aligns the times to the closest frame times (e.g. beats).

    Parameters
    ----------
    times: np.ndarray
        Times in seconds to be aligned.
    frames: np.ndarray
        Frame times in seconds.

    Returns
    -------
    aligned_times: np.ndarray
        Aligned times.