Compare commits
2
Commits
52acba0dfc
...
28aba97491
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28aba97491 | ||
|
|
e0c35ee033 |
+2
-1
@@ -4,4 +4,5 @@
|
||||
|
||||
__pycache__/
|
||||
.env
|
||||
logs/
|
||||
logs/
|
||||
.serena
|
||||
|
||||
@@ -15,7 +15,7 @@ if os.path.exists('.env'):
|
||||
|
||||
|
||||
# Version
|
||||
VERSION = '1.0.3'
|
||||
VERSION = '1.0.4'
|
||||
|
||||
# Server settings
|
||||
SERVER_HOST = '0.0.0.0'
|
||||
|
||||
@@ -40,6 +40,7 @@ DIAL_CODES = {
|
||||
'*1337#': 'rainbow_nick_toggle', # toggles the dialer's own rainbow nick
|
||||
'*101#': 'knock', # plays a knock sound for everyone in the room
|
||||
'*300#': 'laugh', # plays a laugh sound for everyone in the room
|
||||
'*212#': 'seinfeld', # plays a random 10s slice of the Seinfeld bass riff
|
||||
'*88#': 'voice_changer', # opens the dialer's voice changer popup (local FX)
|
||||
'*666#': 'schizo_toggle', # toggles schizo mode (subtle UI shake/wiggle/morph)
|
||||
'*9059#': 'pong_toggle', # toggles pong mode (webcam tiles bounce around)
|
||||
@@ -57,6 +58,7 @@ DIAL_CODE_DESCRIPTIONS = [
|
||||
('*1337#', 'Toggle rainbow nickname (just you)'),
|
||||
('*101#', 'Play a knock sound (everyone)'),
|
||||
('*300#', 'Play a laugh sound (everyone)'),
|
||||
('*212#', 'Play a random 10s of the Seinfeld bass (everyone)'),
|
||||
('*88#', 'Open the voice changer (just you)'),
|
||||
('*666#', 'Toggle schizo mode (everyone)'),
|
||||
('*9059#', 'Toggle pong mode (everyone)'),
|
||||
@@ -71,6 +73,11 @@ DIAL_CODE_DESCRIPTIONS = [
|
||||
MAX_RECORDING_BYTES = 512 * 1024 # ~500KB cap, plenty for 10s of opus at low bitrate
|
||||
DIAL_MAX_LEN = 32
|
||||
|
||||
# Seinfeld bass riff (static/sounds/seinfeld.mp3). One random start offset is picked
|
||||
# server-side per *212# and broadcast so everyone hears the same slice.
|
||||
SEINFELD_TRACK_LEN = 54 # seconds (actual file is ~54.19s)
|
||||
SEINFELD_CLIP_LEN = 10 # seconds
|
||||
|
||||
|
||||
def generate_captcha():
|
||||
'''Generate a random captcha question and answer'''
|
||||
@@ -517,6 +524,11 @@ async def handle_message(client_id: str, data: dict):
|
||||
elif action == 'laugh':
|
||||
logging.info(f'[{client_id}] Laugh')
|
||||
await broadcast_all({'type': 'play_sound', 'sound': 'laugh'})
|
||||
elif action == 'seinfeld':
|
||||
# Pick one random start so the whole room hears the same 10-second slice.
|
||||
start = round(random.uniform(0, SEINFELD_TRACK_LEN - SEINFELD_CLIP_LEN), 2)
|
||||
logging.info(f'[{client_id}] Seinfeld clip @ {start}s')
|
||||
await broadcast_all({'type': 'play_clip', 'sound': 'seinfeld', 'start': start, 'duration': SEINFELD_CLIP_LEN})
|
||||
elif action == 'voice_changer':
|
||||
# Private trigger - only the dialer's UI opens the voice changer popup. The FX
|
||||
# are applied client-side to the dialer's own outgoing audio.
|
||||
|
||||
@@ -532,6 +532,12 @@ function handleSignal(data) {
|
||||
playSound(data.sound);
|
||||
break;
|
||||
|
||||
case 'play_clip':
|
||||
// Random-slice sound (e.g. *212# Seinfeld). Same car-mode suppression.
|
||||
if (state.settings.carMode) break;
|
||||
playSoundClip(data.sound, data.start, data.duration);
|
||||
break;
|
||||
|
||||
case 'reset_all':
|
||||
setTrippyMode(false);
|
||||
setSchizoMode(false);
|
||||
|
||||
@@ -84,7 +84,8 @@ const SOUND_FILES = {
|
||||
join: '/static/sounds/gta.wav',
|
||||
leave: '/static/sounds/htp.wav',
|
||||
knock: '/static/sounds/knock.mp3',
|
||||
laugh: '/static/sounds/laugh.mp3'
|
||||
laugh: '/static/sounds/laugh.mp3',
|
||||
seinfeld: '/static/sounds/seinfeld.mp3'
|
||||
};
|
||||
const soundElements = {};
|
||||
|
||||
@@ -97,6 +98,41 @@ function getSoundElement(type) {
|
||||
return soundElements[type];
|
||||
}
|
||||
|
||||
// Play a fixed-length slice of a sound file starting at `start` seconds. Used by the
|
||||
// Seinfeld dial code (*212#): the server picks one random start offset and broadcasts it
|
||||
// so everyone hears the same 10-second clip.
|
||||
function playSoundClip(type, start, duration) {
|
||||
if (!state.settings.sounds) return;
|
||||
if (!SOUND_FILES[type]) return;
|
||||
|
||||
const begin = Math.max(0, Number(start) || 0);
|
||||
const dur = Math.max(0.1, Number(duration) || 10);
|
||||
const stopAt = begin + dur;
|
||||
|
||||
try {
|
||||
const a = getSoundElement(type);
|
||||
|
||||
const onTime = () => {
|
||||
if (a.currentTime >= stopAt) {
|
||||
a.pause();
|
||||
a.removeEventListener('timeupdate', onTime);
|
||||
}
|
||||
};
|
||||
|
||||
const startPlayback = () => {
|
||||
try { a.currentTime = begin; } catch (e) {}
|
||||
a.addEventListener('timeupdate', onTime);
|
||||
a.play().catch(e => console.error('[Sound] Clip play failed:', e));
|
||||
};
|
||||
|
||||
a.pause();
|
||||
if (a.readyState >= 1) startPlayback(); // HAVE_METADATA - can seek now
|
||||
else a.addEventListener('loadedmetadata', startPlayback, { once: true });
|
||||
} catch (e) {
|
||||
console.error('[Sound] Clip failed:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function playSound(type) {
|
||||
if (!state.settings.sounds) return;
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user