movis.layer.media.AudioSequence#

class movis.layer.media.AudioSequence(start_times: Sequence[float], end_times: Sequence[float], audio_files: Sequence[str | Path | ndarray])[source]#

Audio sequence layer to handle multiple audio files.

Args:
start_times:

a sequence of start times for each audio.

end_times:

a sequence of end times for each audio.

audio_files:

a sequence of audio data. Each element can be a file path (str or Path) or a numpy.ndarray with a shape of (2, N) and a sampling rate of 44100. If the audio data is a mono channel, it will be broadcasted to a stereo channel.

Methods

get_audio(start_time: float, end_time: float) ndarray | None[source]#

Get the audio data for the given time range.

Args:
start_time:

the start time of the audio data.

end_time:

the end time of the audio data.

Returns:

The audio data for the given time range. If no audio data is found, None is returned.

get_key(time: float) int[source]#

Get the state index for the given time.

Note:

This method always returns a constant value because the audio data does not affect the image data.

Attributes

duration

The duration of the audio sequence.