Skip to content

Commit

Permalink
Add basic support for shared spatial audio
Browse files Browse the repository at this point in the history
  • Loading branch information
mxszym-dolby authored Sep 7, 2023
1 parent cd43809 commit 751f415
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
20 changes: 20 additions & 0 deletions src/app/actions/ConferenceActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,16 @@ export class Actions {
videoProcessor: videoProcessorOptions,
})
.then((res) => {
let participant = VoxeetSDK.session.participant;
if (VoxeetSDK.conference.current.params.spatialAudioStyle === "shared") {
if (participant.type === "user") {
VoxeetSDK.conference.setSpatialPosition(participant, {
x: 0,
y: 0,
z: 0,
});
}
}
dispatch(
ParticipantActions.saveCurrentUser(
userInfo.name,
Expand Down Expand Up @@ -671,6 +681,16 @@ export class Actions {
videoProcessor: videoProcessorOptions,
})
.then((res) => {
let participant = VoxeetSDK.session.participant;
if (VoxeetSDK.conference.current.params.spatialAudioStyle === "shared") {
if (participant.type === "user") {
VoxeetSDK.conference.setSpatialPosition(participant, {
x: 0,
y: 0,
z: 0,
});
}
}
dispatch(
ParticipantActions.saveCurrentUser(
userInfo.name,
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/attendees/modes/MeasuredTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default function MeasuredTile(props) {
);

const onBoundsUpdate = (size) => {
if(VoxeetSDK.conference.current.params.spatialAudioStyle === "shared")
return
const currentBounds = size.bounds;
if (currentBounds) {
const participant = VoxeetSDK.conference.current.participants.get(
Expand Down
30 changes: 17 additions & 13 deletions src/app/libs/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,22 @@ const generatePositionLayout = (
};

const refreshPositionLayout = () => {
const layout = generatePositionLayout(participantsConnected.length);

for (var i = 0; i < participantsConnected.length; i++) {
if (
!excludedParticipants.includes(participantsConnected[i].participant_id)
) {
participantsConnected[i].id = participantsConnected[i].participant_id;
VoxeetSDK.conference.setSpatialPosition(
participantsConnected[i],
layout[i]
);
participantsConnected[i].x = layout[i].x;
participantsConnected[i].y = layout[i].y;
if (VoxeetSDK.conference.current.params.spatialAudioStyle === "shared")
return;
else {
const layout = generatePositionLayout(participantsConnected.length);
for (var i = 0; i < participantsConnected.length; i++) {
if (
!excludedParticipants.includes(participantsConnected[i].participant_id)
) {
participantsConnected[i].id = participantsConnected[i].participant_id;
VoxeetSDK.conference.setSpatialPosition(
participantsConnected[i],
layout[i]
);
participantsConnected[i].x = layout[i].x;
participantsConnected[i].y = layout[i].y;
}
}
}
};
Expand All @@ -361,6 +364,7 @@ export const updateParticipantPositions = (participants) => {
export const updateSpatialScene = (
currentBounds = { width: 1, height: 1, left: 0, top: 0 }
) => {
if(VoxeetSDK.conference.current.params.spatialAudioStyle === "shared") return;
if (currentBounds) {
// Set the scale so the pixel size of the component maps to the audio scene size
const right = { x: 1, y: 0, z: 0 };
Expand Down

0 comments on commit 751f415

Please sign in to comment.