cutcutcodec.core.filter.audio.equation.FilterAudioEquation

class cutcutcodec.core.filter.audio.equation.FilterAudioEquation(in_streams: Iterable[StreamAudio], *signals: Basic | Real | str, layout: Layout | str | Integral = None)[source]

Apply any equation on each channels.

The relation can not mix differents timestamps (no convolution).

Attributes

layoutcutcutcodec.core.classes.layout.Layout

The signification of each channels (readonly).

signalslist[sympy.core.expr.Expr]

The amplitude expression of the differents channels (readonly).

Examples

>>> from cutcutcodec.core.filter.audio.equation import FilterAudioEquation
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
>>> (stream_in,) = GeneratorAudioNoise(0).out_streams
>>> stream_in.snapshot(0, 48000, 4)
FrameAudio(0, 48000, 'stereo', [[ 0.44649088,  0.8031031 , -0.25397146,
                                 -0.1199106 ],
                                [-0.8036704 ,  0.72772765,  0.17409873,
                                  0.42185044]])
>>> (stream_out,) = FilterAudioEquation([stream_in], "fl_0 + t", "fl_0 + fr_0").out_streams
>>> stream_out.snapshot(0, 48000, 4)
FrameAudio(0, 48000, 'stereo', [[ 0.44649088,  0.80312395, -0.2539298 ,
                                 -0.11984809],
                                [-0.35717952,  1.        , -0.07987273,
                                  0.30193985]])
>>>

Initialise and create the class.

Parameters

in_streamstyping.Iterable[Stream]

Transmitted to cutcutcodec.core.classes.filter.Filter.

*signalsstr or sympy.Basic

The amplitude function of each channel respectively. The channels are interpreted like is describe in cutcutcodec.core.classes.frame_audio.FrameAudio. The number of expressions correspond to the number of channels. The return values will be cliped to stay in the range [-1, 1]. If the expression gives a complex, the real part is taken. The variables that can be used in these functions are the following:

  • t : The time in seconds since the beginning of the audio.

  • x_iWith x any channels available

    for cutcutcodec.core.classes.layout.Layout.channels and i the stream index, i starts from 0 included. examples: fl_0 for front left of the stream 0.

layout: cutcutcodec.core.classes.layout.Layout or str or int, optional

The audio layout to associate to each equation, let see cutcutcodec.core.classes.layout.Layout for more details. By default, the layout is automaticaly detected from the number of equations.

property free_symbols: set[Symbol]

Return the set of the diferents used symbols.

property layout: Layout

Return the signification of each channels.

property signals: list[Basic]

Return the amplitude expression of the differents channels.