Skip to content

Commit f6dee16

Browse files
authored
chore: audio retrigger test scene (#65)
1 parent b30bb5a commit f6dee16

15 files changed

Lines changed: 690 additions & 0 deletions

File tree

dcl-workspace.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
{
44
"path": "scenes/9,99-modifier-areas"
55
},
6+
{
7+
"path": "scenes/89,-10-audio-source-retrigger-test"
8+
},
69
{
710
"path": "scenes/88,-13-avatar-masks"
811
},
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.*
2+
bin/*.map
3+
package-lock.json
4+
yarn-lock.json
5+
build.json
6+
export
7+
tsconfig.json
8+
tslint.json
9+
node_modules
10+
*.ts
11+
*.tsx
12+
.vscode
13+
Dockerfile
14+
dist
15+
README.md
16+
*.blend
17+
*.fbx
18+
*.zip
19+
*.rar
20+
src
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package-lock.json
2+
*.js
3+
node_modules
4+
bin/
5+
.DS_Store
6+
**/.DS_Store
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
.editor
11+
.idea
12+
.vscode
13+
dclcontext
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# AudioSource Retrigger Test Scene
2+
3+
Scene at parcel `89,-10` (two parcels: `89,-10` and `90,-10`).
4+
5+
## Purpose
6+
7+
This scene validates two AudioSource fixes that ship on separate branches:
8+
9+
| Branch | Repo | Fix |
10+
|--------|------|-----|
11+
| `fix/audio-source-retrigger-dedup` | `js-sdk-toolchain` | `AudioSource.playSound` / `stopSound` now use `createOrReplace` instead of `getMutableOrNull`. Identical-parameter retriggers always emit a CRDT PUT, so the runtime processes every click. |
12+
| `fix/audio-source-same-url-retrigger` | `unity-explorer` | Same-URL PUT with `playing: true` now seeks to `currentTime` and restarts playback even when Unity's `AudioSource.isPlaying` is already `true`. |
13+
14+
Both fixes are required for the same-URL retrigger scenario (Zone B) to work correctly end-to-end.
15+
16+
---
17+
18+
## Zones
19+
20+
### Zone A — Basic Playback
21+
*Objects A1 and A2, front-left area.*
22+
23+
Uses `AudioSource.createOrReplace` directly — no helpers. Confirms the baseline create-and-play path works.
24+
25+
- **A1 (green)**`createOrReplace(entity, { audioClipUrl: CLIP_A, playing: true, volume: 1 })`. Expected: clip plays every click.
26+
- **A2 (red)**`createOrReplace(entity, { audioClipUrl: CLIP_A, playing: false })`. Expected: clip stops.
27+
28+
### Zone B — Same-URL Retrigger
29+
*Objects B1 and B2, second column.*
30+
31+
One entity is pre-populated with `AudioSource.create(entity, { audioClipUrl: CLIP_LONG, playing: false })` at scene init.
32+
33+
- **B1 (blue)**`AudioSource.playSound(entity, CLIP_LONG)`. Expected after the fix: every click restarts the clip from 0, even if it was already playing. Without the fixes: the second and subsequent clicks are silently ignored by the CRDT dedup or by Unity's `isPlaying` guard.
34+
- **B2 (orange)**`AudioSource.stopSound(entity)`. Expected: clip stops.
35+
36+
### Zone C — URL Swap on the Same Entity
37+
*Objects C1, C2, C3, third column.*
38+
39+
One entity. Each button calls `createOrReplace` with a different clip URL.
40+
41+
- **C1, C2, C3** — swaps to CLIP_A, CLIP_B, CLIP_C respectively, `playing: true`. Expected: clean cut between clips every time; no bleed-over from the previous clip.
42+
43+
### Zone D — resetCursor Semantics
44+
*Objects D1-D4, fourth column.*
45+
46+
One entity pre-populated with the long clip. Exercises the `resetCursor` flag on both `playSound` and `stopSound`.
47+
48+
- **D1**`playSound(entity, CLIP_LONG, true)`. Expected: starts from 0 every click.
49+
- **D2**`playSound(entity, CLIP_LONG, false)`. Expected: resumes from the SDK-mirror `currentTime` (which is 0 at scene start unless you previously set it).
50+
- **D3**`stopSound(entity, true)`. Expected: stops and resets cursor to 0.
51+
- **D4**`stopSound(entity, false)`. Expected: stops but leaves cursor at its current value.
52+
53+
### Zone E — Property Variations
54+
*Objects E1-E4, second row left.*
55+
56+
Four toggle-play entities, each with a different property setting. Clicking any button toggles between `playSound` / `stopSound`.
57+
58+
- **E1**`volume: 0.25` (audibly quiet).
59+
- **E2**`pitch: 0.5` (half-speed, lower tone).
60+
- **E3**`pitch: 2.0` (double-speed, higher tone).
61+
- **E4**`loop: true` (clip restarts continuously until stopped).
62+
63+
### Zone F — getMutable Hand-Mutation vs playSound Helper
64+
*Objects F1 and F2, second row right.*
65+
66+
A side-by-side comparison to document why `playSound` is the correct API.
67+
68+
- **F1 (green)**`AudioSource.playSound(entity, CLIP_SHORT)`. Expected: reliable retrigger on every click because `createOrReplace` always emits a CRDT PUT.
69+
- **F2 (orange)** — sets `getMutable(entity).playing = true` and `.currentTime = 0` by hand. Expected: works on the first click; subsequent clicks may be silently deduped by LWW CRDT if the values did not change.
70+
71+
A sign near F1/F2 explains the difference inline.
72+
73+
---
74+
75+
## Placeholder Audio Files
76+
77+
The following files are intentionally missing — you must supply them before testing:
78+
79+
| Path (relative to scene root) | Description |
80+
|-------------------------------|-------------|
81+
| `audio/placeholder-a.mp3` | Short clip, ~1 s (e.g., a "blip") |
82+
| `audio/placeholder-b.mp3` | Short clip, different timbre |
83+
| `audio/placeholder-c.mp3` | Short clip, different timbre |
84+
| `audio/placeholder-short.mp3` | Very short clip, ~0.5 s |
85+
| `audio/placeholder-long.mp3` | Long clip, ~20 s (so mid-clip retrigger is audibly obvious) |
86+
87+
The scene will build without them. They only produce a missing-asset warning at deployment/preview time.
88+
89+
---
90+
91+
## Local SDK Setup
92+
93+
This scene must consume the locally-built SDK so the fixes under test are what the scene runs against. Run:
94+
95+
```bash
96+
cd /path/to/sdk7-test-scenes/scenes/89,-10-audio-source-retrigger-test
97+
npm install /path/to/js-sdk-toolchain/packages/@dcl/sdk
98+
npm run build
99+
```
100+
101+
Adjust the absolute paths to match your local checkout locations.
102+
103+
---
104+
105+
## Running the Scene
106+
107+
```bash
108+
cd scenes/89,-10-audio-source-retrigger-test
109+
npm run start -- --explorer-alpha
110+
```
111+
112+
Open the preview in the Decentraland Explorer Alpha. Walk to each zone and click the boxes to trigger audio scenarios.
3.82 KB
Binary file not shown.
7.38 KB
Binary file not shown.
11.8 KB
Binary file not shown.
423 KB
Binary file not shown.
4.17 KB
Binary file not shown.
83.6 KB
Loading

0 commit comments

Comments
 (0)