Filters#
A Filter
is used with Player.add_filter()
to modify the playback of a
Track
.
- class mafic.Filter(*, equalizer=None, karaoke=None, timescale=None, tremolo=None, vibrato=None, rotation=None, distortion=None, channel_mix=None, low_pass=None, volume=None)#
Bases:
object
Represents a filter which can be applied to audio.
- x | y
Merges two filters together, favouring attributes from y.
- x |= y
Merges two filters together, favouring attributes from x, assigning to x.
- x & y
Merges two filters together, favouring attributes from x.
- x &= y
Merges two filters together, favouring attributes from y, assigning to x.
Changed in version 2.1:
equalizer
now accepts alist
of any of the following:- distortion#
The distortion filter to use.
- Type:
- channel_mix#
The channel mix filter to use.
- Type:
- class mafic.ChannelMix(left_to_left=None, left_to_right=None, right_to_left=None, right_to_right=None)#
Bases:
object
Represents a filter which can be used to mix the audio channels.
Setting all of these to
0.5
will make the audio mono.- left_to_left#
The amount of the left channel to mix into the left channel. This defaults to
1.0
.
- left_to_right#
The amount of the left channel to mix into the right channel. This defaults to
0.0
.
- right_to_left#
The amount of the right channel to mix into the left channel. This defaults to
0.0
.
- class mafic.Distortion(sin_offset=None, sin_scale=None, cos_offset=None, cos_scale=None, tan_offset=None, tan_scale=None, offset=None, scale=None)#
Bases:
object
Represents a filter which can be used to add a distortion effect to audio.
This applies sine, cosine and tangent distortion to the audio. The formula that is used:
sample_sin = sin_offset + math.sin(sample * sin_scale); sample_cos = cos_offset + math.cos(sample * cos_scale); sample_tan = tan_offset + math.tan(sample * tan_scale); sample = max( -1, min( 1, offset + scale * sample_sin * sample_cos * sample_tan ) )
- class mafic.Karaoke(level=None, mono_level=None, filter_band=None, filter_width=None)#
Bases:
object
Represents a filter which can be used to eliminate part of a band.
This usually targets vocals, to sound like karaoke music.
- level#
The level of the karaoke effect. Must be between
0.0
and1.0
. Where0.0
is no effect and1.0
is full effect. This defaults to1.0
.
- mono_level#
The level of the mono effect. Must be between
0.0
and1.0
. Where0.0
is no effect and1.0
is full effect. This defaults to1.0
.
- class mafic.LowPass(smoothing=None)#
Bases:
object
Represents a filter which can be used to apply a low pass filter to audio.
High frequencies are suppressed, while low frequencies are passed through.
- class mafic.Rotation(rotation_hz=None)#
Bases:
object
Represents a filter which can be used to add a rotating effect to audio.
An example can be with “8D audio” (without the reverb).
- class mafic.Timescale(speed=None, pitch=None, rate=None)#
Bases:
object
Represents a filter which is used to change the speed, pitch and rate of audio.
- class mafic.Tremolo(frequency=None, depth=None)#
Bases:
object
Represents a filter which can be used to add a tremolo effect to audio.
Tremolo oscillates the volume of the audio.
- frequency#
The frequency of the tremolo effect. Must be at least
0.0
. This defaults to2.0
.