Skip to content

08 SFX ​

In this chapter, we will add a sound effect to the tap phase's hit event.

Existing Effect ​

The shared Effects class already declares the standard perfect sound effect from play mode. This code is for reference. Do not edit guide/lib/effect.py:

python
from sonolus.script.effect import StandardEffect, effects


@effects
class Effects:
    # ...

    perfect: StandardEffect.PERFECT

Hit Boundary ​

The tap phase already checks for the hit at the end of the frozen range. This code is for reference. Keep it unchanged:

python
hit_time = frozen.end

# ...

if phase_time.crossed(hit_time):
    play_note_hit_effects()

In guide/tutorial/note.py, add the Effects import shown below with the other guide imports. Then replace the empty play_note_hit_effects function with:

python
from guide.lib.effect import Effects


def play_note_hit_effects():
    Effects.perfect.play()

The sound now plays once when the phase clock crosses the frozen range's end, even if a frame skips past that exact time.