Skip to content

ClipSound class

Bases: pytvpaint.sound.BaseSound['Clip']

A clip sound.

Source code in pytvpaint/sound.py
202
203
204
205
206
207
208
209
210
def __init__(
    self,
    track_index: int,
    clip: Clip | None = None,
) -> None:
    from pytvpaint.clip import Clip

    clip = clip or Clip.current_clip()
    super().__init__(track_index, clip)

clip: Clip property

The sound's clip.

refresh_on_call = True instance-attribute

is_removed: bool property

Checks if the object is removed by trying to refresh its data.

Returns:

Name Type Description
bool bool

whether if it was removed or not

track_index: int property

Get the soundtrack index in the sound stack.

Raises:

Type Description
ValueError

if sound object no longer exists

make_current() -> None

Makes the sound clip current.

Source code in pytvpaint/sound.py
235
236
237
def make_current(self) -> None:
    """Makes the sound clip current."""
    self.clip.make_current()

remove() -> None

Remove the sound from the clip.

Source code in pytvpaint/sound.py
239
240
241
242
243
@set_as_current
def remove(self) -> None:
    """Remove the sound from the clip."""
    george.tv_sound_clip_remove(self.track_index)
    self.mark_removed()

reload() -> None

Reload the sound from file.

Source code in pytvpaint/sound.py
245
246
247
248
@set_as_current
def reload(self) -> None:
    """Reload the sound from file."""
    george.tv_sound_clip_reload(self._parent.id, self.track_index)

refresh() -> None

Refreshes the sound data.

Source code in pytvpaint/sound.py
83
84
85
86
87
88
def refresh(self) -> None:
    """Refreshes the sound data."""
    super().refresh()
    if not self.refresh_on_call and self._data:
        return
    self._data = self._info(self.parent.id, self.track_index)

mark_removed() -> None

Marks the object as removed and is therefor not usable.

Source code in pytvpaint/utils.py
 98
 99
100
def mark_removed(self) -> None:
    """Marks the object as removed and is therefor not usable."""
    self._is_removed = True

iter_sounds_data(parent_id: str | int) -> Iterator[george.TVPSound] classmethod

Returns an iterator over the sound's data.

Source code in pytvpaint/sound.py
66
67
68
69
@classmethod
def iter_sounds_data(cls, parent_id: str | int) -> Iterator[george.TVPSound]:
    """Returns an iterator over the sound's data."""
    return utils.position_generator(lambda track_index: cls._info(parent_id, track_index))

new(sound_path: Path | str, parent: P) -> Self classmethod

Create a new sound from the sound path.

Source code in pytvpaint/sound.py
75
76
77
78
79
80
81
@classmethod
def new(cls: type[Self], sound_path: Path | str, parent: P) -> Self:
    """Create a new sound from the sound path."""
    parent.make_current()
    cls._new(Path(sound_path))
    last_index = len(list(cls.iter_sounds_data(parent.id))) - 1
    return cls(last_index, parent)

offset(value: float) -> None

Source code in pytvpaint/sound.py
109
110
111
@offset.setter
def offset(self, value: float) -> None:
    self._adjust(offset=value)

volume(value: float) -> None

Source code in pytvpaint/sound.py
118
119
120
121
@volume.setter
@set_as_current
def volume(self, value: float) -> None:
    self._adjust(volume=value)

is_muted(value: bool) -> None

Source code in pytvpaint/sound.py
128
129
130
131
@is_muted.setter
@set_as_current
def is_muted(self, value: bool) -> None:
    self._adjust(mute=value)

fade_in_start(value: float) -> None

Source code in pytvpaint/sound.py
138
139
140
141
@fade_in_start.setter
@set_as_current
def fade_in_start(self, value: float) -> None:
    self._adjust(fade_in_start=value)

fade_in_stop(value: float) -> None

Source code in pytvpaint/sound.py
148
149
150
151
@fade_in_stop.setter
@set_as_current
def fade_in_stop(self, value: float) -> None:
    self._adjust(fade_in_stop=value)

fade_out_start(value: float) -> None

Source code in pytvpaint/sound.py
158
159
160
161
@fade_out_start.setter
@set_as_current
def fade_out_start(self, value: float) -> None:
    self._adjust(fade_out_start=value)

fade_out_stop(value: float) -> None

Source code in pytvpaint/sound.py
168
169
170
171
@fade_out_stop.setter
@set_as_current
def fade_out_stop(self, value: float) -> None:
    self._adjust(fade_out_stop=value)

path() -> Path

The sound source file path.

Source code in pytvpaint/sound.py
173
174
175
176
@refreshed_property
def path(self) -> Path:
    """The sound source file path."""
    return self._data.path

sound_in() -> float

The start time of the sound.

Source code in pytvpaint/sound.py
178
179
180
181
@refreshed_property
def sound_in(self) -> float:
    """The start time of the sound."""
    return self._data.sound_in

sound_out() -> float

The end time of the sound.

Source code in pytvpaint/sound.py
183
184
185
186
@refreshed_property
def sound_out(self) -> float:
    """The end time of the sound."""
    return self._data.sound_out

color_index(value: int) -> None

Source code in pytvpaint/sound.py
193
194
195
196
@color_index.setter
@set_as_current
def color_index(self, value: int) -> None:
    self._adjust(color_index=value)