def remix(y, intervals, align_zeros=True):
<EOL>util.valid_audio(y, mono=False)<EOL>y_out = []<EOL>if align_zeros:<EOL><INDENT>y_mono = core.to_mono(y)<EOL>zeros = np.nonzero(core.zero_crossings(y_mono))[-<NUM_LIT:1>]<EOL>zeros = np.append(zeros, [len(y_mono)])<EOL><DEDENT>clip = [slice(None)] * y.ndim<EOL>for interval in intervals:<EOL><INDENT>if align_zeros:<EOL><INDENT>interval = zeros[util.match_events(interval, zeros)]<EOL><DEDENT>clip[-<NUM_LIT:1>] = slice(interval[<NUM_LIT:0>], interval[<NUM_LIT:1>])<EOL>y_out.append(y[tuple(clip)])<EOL><DEDENT>return np.concatenate(y_out, axis=-<NUM_LIT:1>)<EOL>
Remix an audio signal by re-ordering time intervals.


    Parameters
    ----------
    y : np.ndarray [shape=(t,) or (2, t)]
        Audio time series

    intervals : iterable of tuples (start, end)
        An iterable (list-like or generator) where the `i`th item
        `intervals[i]` indicates the start and end (in samples)
        of a slice of `y`.

    align_zeros : boolean
        If `True`, interval boundaries are mapped to the closest
        zero-crossing in `y`.  If `y` is stereo, zero-crossings
        are computed after converting to mono.


    Returns
    -------
    y_remix : np.ndarray [shape=(d,) or (2, d)]
        `y` remixed in the order specified by `intervals`


    Examples
    --------
    Load in the example track and reverse the beats

    >>> y, sr = librosa.load(librosa.util.example_audio_file())


    Compute beats

    >>> _, beat_frames = librosa.beat.beat_track(y=y, sr=sr,
    ...                                          hop_length=512)


    Convert from frames to sample indices

    >>> beat_samples = librosa.frames_to_samples(beat_frames)


    Generate intervals from consecutive events

    >>> intervals = librosa.util.frame(beat_samples, frame_length=2,
    ...                                hop_length=1).T


    Reverse the beat intervals

    >>> y_out = librosa.effects.remix(y, intervals[::-1])