Skip to content

Commit 2e8a491

Browse files
committed
Fix refuel sound: one-shot per game frame, not a looping sound
Refuel plays once per game loop iteration (~12 FPS), producing distinct audible beeps ~83 ms apart. Looping a 20 ms buffer at 50 Hz would collapse them into a continuous tone. Remove from the looping table and fix the Loop? flag in the asset catalog.
1 parent 7f6e5cd commit 2e8a491

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

spec/14-sound.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ playback rate.
151151
| Sound | Buffer | Loop rate | `Update()` responsibility |
152152
|---|---|---|---|
153153
| Engine (×3 variants) | 20 ms | 50 Hz | Start when active, stop when inactive, swap player on speed change |
154-
| Refuel | 20 ms | 50 Hz | Start when refueling, stop when done |
155154
| Low-fuel warning | 848 ms | ~1.18 Hz | Start when flag set, stop when cleared |
156155

157156
### Speed Variant Switching
@@ -187,7 +186,7 @@ The WAV files are written to `html/river-raid/audio/`:
187186
| `engine-normal.wav` | Engine at normal speed | Yes |
188187
| `engine-fast.wav` | Engine at fast speed | Yes |
189188
| `engine-slow.wav` | Engine at slow speed | Yes |
190-
| `refuel.wav` | Refueling beep | Yes |
189+
| `refuel.wav` | Refueling beep | No |
191190
| `low-fuel.wav` | Low fuel warning warble | Yes |
192191
| `fuel-full.wav` | Tank full beep | No |
193192
| `fire.wav` | Missile fire burst | No |
@@ -224,7 +223,20 @@ func loadLoopingSound(ctx *audio.Context, name string) *audio.Player {
224223

225224
Use `audio.Context` with a sample rate of **44100** to match the WAV files.
226225

227-
## 14.7. Implementation Notes
226+
## 14.7. Sound Suppression
227+
228+
Sound is suppressed (all players stopped) in two gameplay sub-states:
229+
230+
- **Scroll-in** (`GameplayScrollIn`): no engine or other sounds while the terrain
231+
is scrolling into view before the player takes control.
232+
- **Paused** (`GameState.Paused == true`): all sound stops while the game is
233+
paused and resumes naturally when the player unpauses.
234+
235+
In both cases `SoundSystem.Update` detects the suppressed condition, stops all
236+
active players, and resets its edge-detection state. Sounds resume automatically
237+
on the next `Update` call that finds the game in a normal playable state.
238+
239+
## 14.8. Implementation Notes
228240

229241
- Pre-compute all sound waveforms as PCM samples at initialization time
230242
- Engine sounds loop seamlessly while the corresponding speed is active

0 commit comments

Comments
 (0)