Skip to content

sonolus.script.effect

Effect

Bases: Record

Sound effect clip.

Usage
Effect(id: int)

id instance-attribute

Effect ID.

is_available()

Return whether the effect clip is available.

loop()

Play the effect clip in a loop until stopped.

Returns:

Type Description
LoopedEffectHandle

A handle to stop the loop.

play(distance=0)

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, distance=0)

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)

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.

LoopedEffectHandle

Bases: Record

Handle to stop a looped effect.

stop()

Stop the looped effect.

ScheduledLoopedEffectHandle

Bases: Record

Handle to stop a scheduled looped effect.

stop(end_time)

Stop the scheduled looped effect.

StandardEffect

Standard sound effect clips.

effect(name)

Define a sound effect clip with the given name.

effects(cls)

Decorator to define effect clips.

Usage
@effects
class Effects:
    miss: StandardEffect.MISS
    other: Effect = effect("other")