cutcutcodec.core.classes.stream_audio.StreamAudio

class cutcutcodec.core.classes.stream_audio.StreamAudio(node)[source]

Representation of any audio stream.

Attributes

layoutcutcutcodec.core.classes.layout.Layout

The signification of each channels (readonly). The number of channels is len(self.layout).

Initialise and create the class.

Parameters

nodecutcutcodec.core.classes.node.Node

The node where this stream comes from. The audit must be conducted in the children’s classes. It is not done here in order to avoid cyclic imports.

node_maincutcutcodec.core.classes.node.Node

In the case this streams comes from cutcutcodec.core.filter.meta_filter.MetaFilter, node_main is the meta filter while node is the subgraph of the meta-filter.

abstract property layout: Layout

Return the signification of each channels.

snapshot(timestamp: Real, rate: Integral | None = None, samples: Integral = 1, *, pad: bool = False) FrameAudio[source]

Extract the closest values to the requested date.

Parameters

timestampnumbers.Real

The absolute time expressed in seconds, not relative to the beginning of the audio. Is the instant of the first sample of the returned frame. For avoid the inacuracies of round, it is recomended to use fractional number.

ratenumbers.Integral, optional

If samples == 1, this argument is ignored. Otherwise is the samplerate of the frame. If provide and samples != 1, allows to deduce the timestamps of the non 0 samples. If non provide and samples != 1, try to call the rate attribute of the stream.

samplesnumbers.Integral, default=1

The number of audio samples per channels to catch.

padboolean, default = False

If True, complete the undefined parts of the signal with 0s rather than raising.

Returns

samplesFrameAudio

Audio samples corresponding to the times provided. This vector is of shape (nb_channels, *timestamp_shape). The values are between -1 and 1.

Raises

cutcutcodec.core.exception.OutOfTimeRange

If we try to get a frame out of the definition range (and pad is False). The valid range is [self.beginning, self.beginning+self.duration]. The range taken is [timestamp, timestamp + samples/rate[.

AttributeError

If the rate attribute has to be defined but is not provides or deductable.

property type: str

Implement cutcutcodec.core.classes.stream.Stream.type.