DEV505 / SOUND LAB / 01
A little warmth.
Ignite, listen, and let it fade. One event takes a campfire from its first spark to its quiet finish.
Try it in Unity
Section titled “Try it in Unity”In Unity’s Project window, open Assets/DEV505/SoundManager/Samples/01-Campfire and double-click Demo.unity. Save your current scene if Unity asks. Press the Editor’s Play button, then click inside the Game view so it receives keyboard input.
| Control | Action |
|---|---|
| F with Game View focused | Ignite or extinguish the fire. |
| Ignite fire / Extinguish fire button | The same toggle, through the HUD. |
Start with the quiet scene. Ignite the fire and listen to the short starting sound. When that recording finishes, the graph begins the continuous crackle and fades it in. Toggle again: the crackle fades out while the extinguish sound plays. The HUD—the labels and controls over the scene—changes immediately. The ending audio, also called the release, is allowed to finish afterward.
What is in the scene?
Section titled “What is in the scene?”| Part | Responsibility |
|---|---|
SoundManager |
Registers the Campfire event and owns playback. |
| Campfire interaction component | Starts/stops by Sounds.Campfire, retains the handle, and updates the lit state. |
| Campfire event | Selects recordings and defines start, loop, and release flow. |
| Listener | Establishes where the 3D sound is heard. |
| HUD, light, and voxel particles | Visual feedback driven by the demo controller; these are not generated by the audio graph. |
The static model contains the stones, coals, and straight logs. Flames, smoke, and embers are particle effects. The screenshot captures use the actual scene camera and final Game View, including the HUD.
Read the graph
Section titled “Read the graph”A node is one block in this graph, and a port is one of its connection points. Connections can pass a value, such as which recording to use, or trigger an action, such as starting playback. A voice is one recording currently using a playback slot. If you have not edited a graph before, start with Make your first sound graph.
1. Ignition
Section titled “1. Ignition”On Start → Play Audio (ignition) plays the trimmed Fire_start_01 recording. It is a one-shot with a 0.05-second fade-in. The branch does not start the loop on the same flow output: the ignition node’s Finished output triggers it when the starting cue ends.
2. Continuous crackle
Section titled “2. Continuous crackle”Two Wave Assets, Fire_01 and Fire_02, feed Random Clip. Its selected asset feeds the looping Play Audio node. That node fades in over 2 seconds. Intensity connects to Volume, so it controls the crackle’s level instead of the whole event’s ignition/extinguish cues.
This is a selected recording played as a loop; it is not a new SoundBus.Play call every frame. The demo keeps one event handle alive.
3. Release
Section titled “3. Release”On Stop reaches the ignition and loop nodes’ Stop ports and the extinguish node’s Play port. The explicit Stop connections apply those nodes’ fade-outs—0.3 seconds for ignition, 0.6 seconds for crackle. The new extinguish voice uses the trimmed Fire_end_01 asset and finishes naturally.
Calling stop is therefore the beginning of the ending, not necessarily an immediate silence. The runtime retires the stopping event once its release work finishes; faded voices can also be managed separately by the service.
Event and parameter settings
Section titled “Event and parameter settings”| Setting | Current value | Meaning |
|---|---|---|
| Event key | Sounds.Campfire |
Resolves the registered Campfire event. |
| Spatial blend | 1 | Fully 3D playback. |
| Min / max distance | 2 / 20 | Distances that shape how volume falls as the listener moves away. |
| Owner loss | Stop | Losing the owner/follow target stops the play according to the event’s policy. |
| Max instances | 8 | Event-level ceiling; the demo controller itself retains just one active fire. |
| Concurrency | ReplaceOldest | At the event’s overlap limit, replace its oldest play. |
Intensity |
Float, 0–1; default 0.65 | Crackle volume, smoothed up/down at 0.5 units per second. |
There are no authored signals in this graph and no intensity slider in the current Campfire HUD. Code can still set the exposed parameter.
The integration in code
Section titled “The integration in code”The demo starts with one key-based call and keeps the accepted handle:
var result = SoundBus.Play(Sounds.Campfire, transform);if (result.Accepted) fire = result.Handle;It later asks the same play to stop:
SoundBus.Stop(fire, fade: 0.15f);fire = default;Read Start, loop, and stop for the complete component with rejected-request handling, repeated-start protection, and OnDisable cleanup. The SoundBus reference explains the overloads and the difference between following and owning.
Common surprises
Section titled “Common surprises”- The HUD says the fire is out, but you still hear it. The UI flips immediately; the graph’s fade and release cue continue.
- Changing the API fade does not change every tail. Explicit graph Stop ports use their node fade-out values; the API fade is the fallback for other existing voices.
- Starting every frame stacks sounds. Retain a handle and check
SoundBus.IsAlivebefore starting another loop. - Moving away makes it quieter. This is a spatial event. Check the listener and distance before changing volumes.
- Intensity does not make the flames bigger. Here it controls audio only. Particle/light behavior belongs to the demo controller.