Objects#
- class harmonize.objects.LoadResult(load_type: ~harmonize.enums.load_type.LoadType, tracks: list[~harmonize.objects.track.Track], playlist_info: ~harmonize.objects.playlist_info.PlaylistInfo = <harmonize.objects.PlaylistInfo selected_track=-1>, plugin_info: dict[str, any] | None = None, error: ~harmonize.objects.load_result.LoadError | None = None)[source]#
Represents the result of a load operation.
Operations#
- x[key]
Returns the value of a given attribute of the LoadResult object.
- load_type#
The type of load operation.
- Type:
- playlist_info#
The playlist information. If the load operation is not a playlist, this will be None.
- tracks#
The decoded Track objects.
- Type:
list[
harmonize.objects.Track]
- plugin_info#
Additional plugin information associated with the load operation, if applicable.
- error#
The load error, if applicable.
- Type:
Optional[
harmonize.objects.LoadError]
- classmethod from_dict(mapping: dict) LoadResult[source]#
Creates a LoadResult instance from a dictionary.
- Parameters:
mapping (dict) – A dictionary containing the data to create the LoadResult instance.
- Return type:
- class harmonize.objects.PlaylistInfo(name: str, selected_track: int = -1)[source]#
Represents the information about a playlist.
Operations#
- x[key]
Returns the value of a given attribute of the LoadResult object.
- selected_track#
The index of the selected track in the playlist. If no track is selected, it defaults to -1.
- Type:
- classmethod from_dict(mapping: dict[str, any]) PlaylistInfo[source]#
Creates a new instance of the PlaylistInfo class from a dictionary.
- classmethod none() PlaylistInfo[source]#
Creates a new instance of the PlaylistInfo class with default values.
- Returns:
PlaylistInfo
- class harmonize.objects.Stats(node: Node, data: dict[str, any])[source]#
Represents the statistics of a Lavalink node.
- class harmonize.objects.Track(data: dict[str, str | None | bool | int])[source]#
Represents a track.
Operations#
- x[key]
Returns the value of a given attribute of the LoadResult object.
- plugin_info#
Additional plugin information associated with the track, if applicable.
- user_data#
Additional user data associated with the track, if applicable.
- classmethod from_dict(mapping: dict) Track[source]#
Create a new instance of the Track class from a dictionary mapping.
- Parameters:
mapping (dict) – A dictionary containing the mapping data for the Track object.
- Return type:
- classmethod from_encode(track: str, source_decoders: dict[str, Callable[[DataReader], dict[str, any]]] = None) Track[source]#
Decodes a track from a given string representation.
- Parameters:
track (str) – The string representation of the track to be decoded.
source_decoders (dict[str, Callable[[
harmonize.utils.DataReader], dict[str, any]]]) – A dictionary mapping source names to their respective decoding functions. These functions take a DataReader object as input and return a dictionary containing the decoded source-specific fields. If not provided, the function will use the default decoders from DEFAULT_DECODER_MAPPING.
- Returns:
An instance of the Track class representing the decoded track.
- Return type:
Filters#
All custom filters must derive from Filter
- class harmonize.objects.Equalizer(gains: list[float] = None)[source]#
Represents an equalizer filter. Extended from
harmonize.abstract.Filter- update(*, bands: list[tuple[int, float]]) None[source]#
- update(*, band: int, gain: int) None
Updates the equalizer filter with new gain values.
Note
Bands must be a list of tuples (band: int, gain: float) Band between 0 and 14, and gain between -0.25 and 1.0
- Parameters:
**kwargs (Keyword arguments containing the new gain values. See above)
- Raises:
ValueError – If the provided gain values are out of range.
KeyError – If neither ‘bands’ nor ‘band’ and ‘gain’ are provided.
- Return type:
None
- class harmonize.objects.Karaoke(level: float = 1.0, mono_level: float = 1.0, filter_band: float = 220.0, filter_width: float = 100.0)[source]#
Represents a karaoke filter. Extended from
harmonize.abstract.Filter- update(*, level: float) None[source]#
- update(*, mono_level: float) None
- update(*, filter_band: float) None
- update(*, filter_width: float) None
- update(*, level: float, mono_level: float) None
- update(*, level: float, filter_width: float) None
- update(*, level: float, filter_band: float) None
- update(*, mono_level: float, filter_width: float) None
- update(*, mono_level: float, filter_band: float) None
- update(*, filter_band: float, filter_width: float) None
- update(*, level: float, mono_level: float, filter_width: float) None
- update(*, level: float, mono_level: float, filter_band: float) None
- update(*, level: float, mono_level: float, filter_band: float, filter_width: float) None
Update the values of the Karaoke filter object.
- Parameters:
(dict) (**kwargs)
- Return type:
None
- class harmonize.objects.Timescale(speed: float = 1.0, pitch: float = 1.0, rate: float = 1.0)[source]#
Represents a timescale filter. Extended from
harmonize.abstract.Filter- update(*, speed: float) None[source]#
- update(*, pitch: float) None
- update(*, rate: float) None
- update(*, speed: float, pitch: float) None
- update(*, speed: float, rate: float) None
- update(*, rate: float, pitch: float) None
- update(*, speed: float, rate: float, pitch: float) None
Updates the Timescale filter with new values for speed, pitch, and/or rate.
Note
All new values must be greater than or equal to 0.
- Parameters:
**kwargs (A dictionary containing the new values for speed, pitch, and/or rate.)
- Raises:
ValueError – If any of the new values for speed, pitch, and/or rate are not greater than 0.
- Return type:
None
- class harmonize.objects.Tremolo(frequency: float = 2.0, depth: float = 0.5)[source]#
Represents a tremolo filter. Extended from
harmonize.abstract.Filter- update(*, frequency: float) None[source]#
- update(*, depth: float) None
- update(*, frequency: float, depth: float) None
Updates the tremolo effect values.
Note
Frequency must be bigger than 0. Depth must be bigger than 0, and less than or equal to 1.
- Parameters:
**kwargs (Keyword arguments containing the tremolo effect values to update.)
- Raises:
ValueError – If either frequency or depth are not valid.
- Return type:
None
- class harmonize.objects.Vibrato(frequency: float = 2.0, depth: float = 0.5)[source]#
Represents a vibrato filter. Extended from
harmonize.abstract.Filter- update(*, frequency: float) None[source]#
- update(*, depth: float) None
- update(*, frequency: float, depth: float) None
Updates the vibrato effect values.
Note
Frequency must be bigger than 0, and less than or equal to 14. Depth must be bigger than 0, and less than or equal to 1.
- Parameters:
**kwargs (Keyword arguments containing the vibrato effect values to update.)
- Raises:
ValueError – If either frequency or depth are not valid.
- Return type:
None
- class harmonize.objects.Rotation(rotation_hz: float = 0.0)[source]#
Represents a rotation filter. Extended from
harmonize.abstract.Filter
- class harmonize.objects.LowPass(smoothing: float = 20.0)[source]#
Represents a low pass filter. Extended from
harmonize.abstract.Filter
- class harmonize.objects.ChannelMix(left_to_left: float = 1.0, left_to_right: float = 0.0, right_to_left: float = 0.0, right_to_right: float = 0.0)[source]#
Represents a channel mix filter. Extended from
harmonize.abstract.Filter- update(left_to_left: float) None[source]#
- update(left_to_right: float) None
- update(right_to_left: float) None
- update(right_to_right: float) None
Updates the channel mix values of the filter.
Note
All parameters must be bigger than or equal to 0, and less than or equal to 1.
- Parameters:
**kwargs – A dictionary containing the new channel mix values to update.
- Returns:
This function does not return any value. It updates the internal state of the filter.
- Return type:
None
- Raises:
ValueError – If any of the new channel mix values are not within the range [0, 1].
- class harmonize.objects.Volume(volume: float = 1.0)[source]#
Represents a volume filter. Extended from
harmonize.abstract.Filter- update(*, volume: float) None[source]#
Modifies the player volume.
Note
Volume must be bigger than or equal to 0, and less than or equal to 5
- Parameters:
volume (float) – The new volume of the player. 1.0 means 100%/default.
- Raises:
ValueError – If volume is not within the valid range.
- Return type:
None
- class harmonize.objects.Distortion(sin_offset: float = 0.0, sin_scale: float = 1.0, cos_offset: float = 0.0, cos_scale: float = 1.0, tan_offset: float = 0.0, tan_scale: float = 1.0, offset: float = 0.0, scale: float = 1.0)[source]#
Represents a distortion filter. Extended from
harmonize.abstract.Filter- update(sin_offset: float) None[source]#
- update(sin_scale: float) None
- update(cos_offset: float) None
- update(cos_scale: float) None
- update(tan_offset: float) None
- update(tan_scale: float) None
- update(offset: float) None
- update(scale: float) None
Updates the distortion filter’s values.
- Parameters:
**kwargs (Keyword arguments to update the filter's values. See above)
- Return type:
None