Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for shared spatial audio #275

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading