@newgameplusinc/odyssey-audio-video-sdk-dev 1.0.36 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -243,7 +243,11 @@ class SpatialAudioManager extends EventManager_1.EventManager {
243
243
  */
244
244
  setParticipantMuted(participantId, muted) {
245
245
  const nodes = this.participantNodes.get(participantId);
246
- if (nodes?.gain) {
246
+ if (!nodes) {
247
+ // Audio nodes don't exist yet - this is normal if called before consumer is set up
248
+ return;
249
+ }
250
+ if (nodes.gain) {
247
251
  // Set gain to 0 (muted) or 1 (unmuted) immediately
248
252
  nodes.gain.gain.setValueAtTime(muted ? 0 : 1, this.audioContext.currentTime);
249
253
  }
package/dist/index.d.ts CHANGED
@@ -95,11 +95,6 @@ export declare class OdysseySpatialComms extends EventManager {
95
95
  /**
96
96
  * Mute another participant (owner only)
97
97
  */
98
- /**
99
- * Update mute state for all participants based on channel matching
100
- * Called when local user switches channels
101
- */
102
- private updateAllParticipantsMuteState;
103
98
  muteParticipant(participantId: string): Promise<{
104
99
  success?: boolean;
105
100
  error?: string;
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
52
52
  isLocal: true,
53
53
  producers: new Map(),
54
54
  consumers: new Map(),
55
+ currentChannel: "spatial",
55
56
  };
56
57
  // 4. Initialize room state
57
58
  this.room = {
@@ -232,10 +233,6 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
232
233
  ? Array.from(this.room.participants.values())
233
234
  : [];
234
235
  this.emit("all-participants-update", normalizedParticipants);
235
- // CRITICAL: After receiving channel data, update ALL mute states
236
- // This ensures existing audio consumers get the correct mute state
237
- console.log(`📊 [all-participants-update] Received ${normalizedParticipants.length} participants, updating mute states...`);
238
- this.updateAllParticipantsMuteState();
239
236
  });
240
237
  this.socket.on("new-participant", (participantData) => {
241
238
  if (this.room) {
@@ -321,24 +318,11 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
321
318
  return; // Exit early to prevent any audio processing
322
319
  }
323
320
  else {
324
- // Check if participant is in huddle - if so, skip spatial audio
325
- const participantChannel = participant.currentChannel || "spatial";
326
- const myChannel = this.localParticipant?.currentChannel || "spatial";
327
- const isInHuddle = participantChannel !== "spatial";
328
- console.log(`🎧 Setting up audio for ${participant.participantId?.substring(0, 8)}`);
329
- console.log(` My channel: ${myChannel}`);
330
- console.log(` Their channel: ${participantChannel}`);
331
- // Setup spatial audio with full 3D positioning (disabled for huddle users)
332
- await this.spatialAudioManager.setupSpatialAudioForParticipant(participant.participantId, track, isInHuddle // Disable spatial audio for huddle users
321
+ // Setup spatial audio with full 3D positioning
322
+ await this.spatialAudioManager.setupSpatialAudioForParticipant(participant.participantId, track, false // Always enable spatial audio
333
323
  );
334
- // CRITICAL: Mute if not in same channel
335
- const shouldMute = myChannel !== participantChannel;
336
- console.log(` Should mute: ${shouldMute} (channels ${myChannel === participantChannel ? 'MATCH' : 'DIFFER'})`);
337
- this.spatialAudioManager.setParticipantMuted(participant.participantId, shouldMute);
338
- // Only update spatial audio position if NOT in huddle
339
- if (!isInHuddle) {
340
- this.spatialAudioManager.updateSpatialAudio(participant.participantId, data.position);
341
- }
324
+ // Update spatial audio position
325
+ this.spatialAudioManager.updateSpatialAudio(participant.participantId, data.position);
342
326
  }
343
327
  // NOW resume the consumer after audio pipeline is ready
344
328
  this.mediasoupManager
@@ -431,34 +415,13 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
431
415
  this.emit("huddle-ended", data);
432
416
  });
433
417
  this.socket.on("participant-channel-changed", (data) => {
434
- console.log(`📡 participant-channel-changed: ${data.participantId?.substring(0, 8)} → ${data.channelId}`);
435
418
  const participant = this.room?.participants.get(data.participantId);
436
419
  if (participant) {
437
420
  participant.currentChannel = data.channelId;
438
- // Toggle spatial audio based on channel
439
- const isInHuddle = data.channelId !== "spatial";
440
- // Update spatial audio bypass state for this participant
441
- if (participant.audioTrack) {
442
- this.spatialAudioManager.setupSpatialAudioForParticipant(participant.participantId, participant.audioTrack, isInHuddle // Disable spatial for huddle, enable for spatial
443
- ).catch(err => {
444
- console.error(`Failed to update spatial audio for ${participant.participantId}:`, err);
445
- });
446
- }
447
- // CRITICAL: Mute/unmute based on channel matching
448
- const myChannel = this.localParticipant?.currentChannel || "spatial";
449
- const theirChannel = data.channelId || "spatial";
450
- const shouldMute = myChannel !== theirChannel;
451
- console.log(` My channel: ${myChannel}, Their channel: ${theirChannel}`);
452
- console.log(` ${shouldMute ? '🔇 MUTING' : '🔊 UNMUTING'} ${participant.participantId?.substring(0, 8)}`);
453
- this.spatialAudioManager.setParticipantMuted(participant.participantId, shouldMute);
454
421
  }
455
422
  // Update local participant if it's them
456
423
  if (this.localParticipant?.participantId === data.participantId && this.localParticipant !== null) {
457
- console.log(` This is ME changing channel!`);
458
424
  this.localParticipant.currentChannel = data.channelId;
459
- // When LOCAL user changes channel, update ALL other participants' mute state
460
- console.log(` 🔄 Updating ALL participants mute state`);
461
- this.updateAllParticipantsMuteState();
462
425
  }
463
426
  this.emit("participant-channel-changed", data);
464
427
  });
@@ -533,8 +496,6 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
533
496
  if (response.success && this.localParticipant) {
534
497
  console.log(`✅ [joinHuddle] Success! New channel: ${response.channelId}`);
535
498
  this.localParticipant.currentChannel = response.channelId;
536
- // CRITICAL: Update mute state for all participants when joining huddle
537
- this.updateAllParticipantsMuteState();
538
499
  }
539
500
  else {
540
501
  console.error(`❌ [joinHuddle] Failed:`, response.error);
@@ -559,8 +520,6 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
559
520
  if (response.success && this.localParticipant) {
560
521
  console.log(`✅ [leaveHuddle] Success! New channel: ${response.channelId}`);
561
522
  this.localParticipant.currentChannel = response.channelId;
562
- // CRITICAL: Update mute state for all participants when leaving huddle
563
- this.updateAllParticipantsMuteState();
564
523
  }
565
524
  else {
566
525
  console.error(`❌ [leaveHuddle] Failed:`, response.error);
@@ -582,27 +541,6 @@ class OdysseySpatialComms extends EventManager_1.EventManager {
582
541
  /**
583
542
  * Mute another participant (owner only)
584
543
  */
585
- /**
586
- * Update mute state for all participants based on channel matching
587
- * Called when local user switches channels
588
- */
589
- updateAllParticipantsMuteState() {
590
- if (!this.localParticipant || !this.room)
591
- return;
592
- const myChannel = this.localParticipant.currentChannel || "spatial";
593
- console.log(`🔄 [updateAllParticipantsMuteState] My channel: ${myChannel}`);
594
- this.room.participants.forEach((participant) => {
595
- // Skip local participant (never hear yourself)
596
- if (participant.participantId === this.localParticipant?.participantId) {
597
- return;
598
- }
599
- const theirChannel = participant.currentChannel || "spatial";
600
- const shouldMute = myChannel !== theirChannel;
601
- console.log(` ${participant.participantId?.substring(0, 8)}: channel=${theirChannel}, ${shouldMute ? '🔇 MUTE' : '🔊 UNMUTE'}`);
602
- this.spatialAudioManager.setParticipantMuted(participant.participantId, shouldMute);
603
- });
604
- console.log(`✅ [updateAllParticipantsMuteState] Complete`);
605
- }
606
544
  async muteParticipant(participantId) {
607
545
  if (!this.localParticipant || !this.room) {
608
546
  return { success: false, error: "Not in a room" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newgameplusinc/odyssey-audio-video-sdk-dev",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "description": "Odyssey Spatial Audio & Video SDK using MediaSoup for real-time communication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",