sonolus.script.effect¶
Effect
¶
Bases: Record
Sound effect clip.
Usage
Effect(id: int)
id: int
instance-attribute
¶
Effect ID.
is_available: bool
property
¶
Return whether the effect clip is available.
loop() -> LoopedEffectHandle
¶
Play the effect clip in a loop until stopped.
Returns:
| Type | Description |
|---|---|
LoopedEffectHandle
|
A handle to stop the loop. |
play(distance: float = 0) -> None
¶
Play the effect clip.
If the clip was already played within the specified distance, it will be skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
float
|
Minimum time in seconds since the last play for the effect to play. |
0
|
schedule(time: float, distance: float = 0) -> None
¶
Schedule the effect clip to play at a specific time.
This is not suitable for real-time effects such as responses to user input.
Use play instead.
This may be called in preprocess to schedule effects upfront.
If the clip would play within the specified distance of another play, it will be skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Time in seconds when the effect should play. |
required |
distance
|
float
|
Minimum time in seconds after a previous play for the effect to play. |
0
|
schedule_loop(start_time: float) -> ScheduledLoopedEffectHandle
¶
Schedule the effect clip to play in a loop until stopped.
This is not suitable for real-time effects such as responses to user input.
Use loop instead.
Returns:
| Type | Description |
|---|---|
ScheduledLoopedEffectHandle
|
A handle to stop the loop. |
EffectGroup
¶
LoopedEffectHandle
¶
ScheduledLoopedEffectHandle
¶
StandardEffect
¶
Standard sound effect clips.
effect(name: str) -> Any
¶
Define a sound effect clip with the given name.
effect_group(names: Iterable[str]) -> Any
¶
Define an effect group with the given names.
effects(cls: type[T]) -> T | Effects
¶
Decorator to define effect clips.
Usage
@effects
class Effects:
miss: StandardEffect.MISS
other: Effect = effect("other")
group_1: EffectGroup = effect_group(["one", "two", "three"])
group_2: EffectGroup = effect_group(f"name_{i}" for i in range(10))