feat: add sound system (LS.sfx) — synthesized Web Audio API sounds for classroom, gamification, quiz

- New js/sound.js: shared LS.sfx module with 21 synthesized sounds (ADSR envelope, sequences, sweeps, noise)
- Classroom: lesson_start/end, user_joined/left, hand_raise, chat_message, muted, draw_permitted
- Dashboard: achievement, level_up, xp_gain, coin via SSE events
- Live quiz: quiz_start, quiz_end on question launch and results
- Settings panel: global enable toggle + volume slider + localStorage persistence
- Replaces old _crBeep() in classroom.html

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-04-14 19:43:13 +03:00
parent d2bf3aba47
commit 29aa985504
4 changed files with 391 additions and 17 deletions
+10
View File
@@ -1521,6 +1521,7 @@
</div>
<script src="/js/api.js"></script>
<script src="/js/sound.js"></script>
<script src="/js/sidebar.js"></script>
<script src="/js/notifications.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
@@ -3626,6 +3627,15 @@
} else if (ev.type === 'session') {
LS.toast(ev.message, 'info');
if (isTeacher) loadAdminSessions();
} else if (ev.type === 'achievement') {
if (window.LS && LS.sfx) LS.sfx.play('achievement');
} else if (ev.type === 'xp_update') {
if (window.LS && LS.sfx) {
if (ev.levelUp) LS.sfx.play('level_up');
else LS.sfx.play('xp_gain');
}
} else if (ev.type === 'coins') {
if (window.LS && LS.sfx) LS.sfx.play('coin');
}
});