JS TS

connect


function connect(
  ticket,
  data,
  domParentId,
  position,
  rotation,
  attrs = {},
  url = "https://panaudia.com/entrance") {...}
interface Vec3 {
  x: number
  y: number
  z: number
}
function connect(
  ticket: string,
  data: boolean,
  domParentId: string,
  position: Vec3,
  rotation: Vec3,
  attrs: { [key: string]: string }={},
  url: string="https://panaudia.com/gateway",
): void {...}

Connects to the Space via WebRTC, setting up two way audio and data channels.

ticket

This is a ticket for the space in the form of a signed JWT token. You can fetch these with the Shapes API or generate and sign them yourself. You can read more about tickets here.

data

If true the Space server will send this client attribute and state messages in WebRTC data channels giving updates about other users in the same Space. Set this to true to use setStateCallback, setAmbisonicStateCallback or setAttributesCallback.

domParentId

This must be the id of an existing dom element to which the audio player for the incoming WebRTC audio will be added.

position

This sets the initial position of this user in the virtual audio space.

rotation

This sets the initial rotation of the user in the virtual audio space.

attrs

You can, optionally, set some string attributes here that will be passed to all other users via the AttributesCallback in the connection field. See setAttributesCallback below. This can be useful to customise the appearance of the user.

url

This is where the SDK will connect to look up the actual connection url for the Space. You can usually omit this and use the default.

JS TS

connectAmbisonic


function connectAmbisonic(
  ticket,
  domParentId,
  coordinates,
  attrs = {},
  url = "https://panaudia.com/entrance") {...}
interface AmbisonicCoordinates {
    x: number
    y: number
    z: number
    yaw: number
    pitch: number
    roll: number
}

function connectAmbisonic(
  ticket: string,
  domParentId: string,
  coordinates: AmbisonicCoordinates,
  attrs: { [key: string]: string }={},
  url: string="https://panaudia.com/entrance",
): void {...}

This is an alternative version of the connect function above that uses native ambisonic coordinates rather than WebGL ones.

ticket

This is a ticket for the space in the form of a signed JWT token. You can fetch these with the Shapes API or generate and sign them yourself. You can read more about tickets here.

domParentId

This must be the id of an existing dom element to which the audio player for the incoming WebRTC audio will be added.

coordinates

This sets the initial position and rotation of this user in the virtual audio space.

attrs

You can, optionally, set some string attributes here that will be passed to all other users via the AttributesCallback in the connection field. See setAttributesCallback below. This can be useful to customise the appearance of the user.

url

This is where the SDK will connect to look up the actual connection url for the Space. You can usually omit this and use the default.

JS TS

move


function move(position, rotation) {...}
interface Vec3 {
  x: number
  y: number
  z: number
}

function move(position: Vec3, rotation: Vec3): void {...}

When the position and/or rotation of the user changes update the mixer.

position

This new position of the user in the virtual audio space.

rotation

The new rotation of the user in the virtual audio space.

JS TS

moveAmbisonic


function moveAmbisonic(coordinates) {...}
interface AmbisonicCoordinates {
    x: number
    y: number
    z: number
    yaw: number
    pitch: number
    roll: number
}

function moveAmbisonic(coordinates: AmbisonicCoordinates): void {...}

An alternative version of the move function above that uses native ambisonic coordinates rather than position and rotation.

coordinates

The new position and rotation of this user in the virtual audio space.

JS TS

disconnect


function disconnect() {...}
function disconnect(): void {...}

Disconnects from the server and stops using the users microphone.

It is possible to call connect again after calling disconnect.

JS TS

setConnectionStatusCallback


function setConnectionStatusCallback(statusCallback) {...}
type ConnectionStatus =
  | "connecting"
  | "connected"
  | "data_connected"
  | "disconnected"
  | "error";

interface ConnectionStatusCallback {
    (status: ConnectionStatus, message: string): void
}

function setConnectionStatusCallback(statusCallback: ConnectionStatusCallback) {...}

The SDK will call the callback with connection status updates

statusCallback

A function with two parameters:

  • status - one of "connecting", "connected", "data_connected", "disconnected" or "error".
  • message - a human-readable message.
JS TS

setStateCallback


function setStateCallback(stateCallback) {...}
interface Vec3 {
  x: number
  y: number
  z: number
}

interface NodeState {
  uuid: string
  position: Vec3
  rotation: Vec3
  volume: number
  gone: boolean
}

interface StateCallback {
  (state: NodeState): void
}

function setStateCallback(stateCallback: StateCallback): void {...}

The SDK will call the callback with state updates for all the other users in the Space giving their uuid, position, rotation, volume and if then have left the Space. This callback is called with quite high frequency (~20Hz per user).

stateCallback

A function with one parameter that is an object with these values:

  • uuid - string giving the UUID of the user.
  • position - an object with x, y, z coordinates of the user.
  • rotation - an object with x, y, z rotation angles of the user.
  • volume - a number giving the volume of the user.
  • gone - a bool true if the user has left the Space.
JS TS

setAmbisonicStateCallback


function setAmbisonicStateCallback(ambisonicStateCallback) {...}
interface AmbisonicNodeState {
  uuid: string
  x: number
  y: number
  z: number
  yaw: number
  pitch: number
  roll: number
  volume: number
  gone: boolean
}

interface AmbisonicStateCallback {
  (state: AmbisonicNodeState): void
}

function setAmbisonicStateCallback(ambisonicStateCallback: AmbisonicStateCallback): void {...}

An alternative version of the move function above that uses native ambisonic coordinates rather than position and rotation.

ambisonicStateCallback

A function with one parameter that is an object with these values:

  • uuid - string giving the UUID of the user.
  • x - the x position coordinate of the user.
  • y - the y position coordinate of the user.
  • z - the z position coordinate of the user.
  • yaw - the yaw of the user.
  • pitch - the pitch of the user.
  • roll - the roll of the user.
  • volume - a number giving the volume of the user.
  • gone - a bool true if the user has left the Space.
JS TS

setAttributesCallback


function setAttributesCallback(attributesCallback) {...}
interface NodeAttributes {
  uuid: string
  name: string
  ticket: { string: any }
  connection: { string: any }
}

interface AttributesCallback {
  (attrs: NodeAttributes): void
}

function setAttributesCallback(attributesCallback: AttributesCallback): void {...}

The SDK will call the attributesCallback with and object giving descriptive information about other users in the Space.

This callback is called with a lower frequency than the state callback.

attributesCallback

A function with one parameter that is an object with these values:

  • uuid - string giving the UUID of the user.
  • name - a display name for the user.
  • ticket - an object with custom attributes for the user that were baked into their ticket when it was created.
  • connection - an object with custom attributes for the user that come from the user's connection.