Skip to main content

@4players/odin

npm npm npm

ODIN is a versatile cross-platform Software Development Kit (SDK) engineered to seamlessly integrate real-time voice chat into multiplayer games, applications, and websites. Regardless of whether you're employing a native application or your preferred web browser, ODIN simplifies the process of maintaining connections with your significant contacts. Through its intuitive interface and robust functionality, ODIN enhances interactive experiences, fostering real-time engagement and collaboration across various digital platforms.

You can choose between a managed cloud and a self-hosted solution. Let 4Players GmbH deal with the setup, administration and bandwidth costs or run our server software on your own infrastructure allowing you complete control and customization of your deployment environment.

Online Documentation

Features

Advanced Audio Processing

ODIN enhances your audio experience during VoIP chats by offering a comprehensive set of filters beyond the basic audio processing features found in web browsers. These enhancements activated by default, ensuring clear and interruption-free communication.

  • Voice Activity Detection
    When enabled, ODIN will analyze the audio input signal using smart voice detection algorithm to determine the presence of speech. You can define both the probability required to start and stop transmitting.
  • Input Volume Gate
    When enabled, the volume gate will measure the volume of the input audio signal, thus deciding when a user is speaking loud enough to transmit voice data. You can define both the root mean square power (dBFS) for when the gate should engage and disengage.

WebTransport (HTTP/3) support

We use the latest WebTransport API to transmit voice data in real time, with a seamless fallback to WebRTC for compatibility with older browsers.

End-to-End Encryption (Cipher)

ODIN supports end-to-end encryption (E2EE) through the use of a pluggable OdinCipher module. This enables you to secure all datagrams, messages and peer user data with a shared room password - without relying on the server as a trust anchor.

Quick Start

Ready to take your app to the next level? Integrating ODIN is a simple and straightforward process. Here are two examples of how to get started with our SDK.

TypeScript Example

The following code snippet illustrates how to how to start ODIN in a JavaScript project:

import {
init,
Plugin,
Room,
DeviceManager,
AudioInput,
} from '@4players/odin';
import { createPlugin } from '@4players/odin-plugin-web';

let audioPlugin;
let room;
let audioInput;

const initPlugin = async () => {
if (audioPlugin) return audioPlugin;
// Creates the plugin.
audioPlugin = createPlugin(async (sampleRate) => {
const audioContext = new AudioContext({ sampleRate });
await audioContext.resume();
return audioContext;
});
// Initializes the plugin.
init(audioPlugin);
return audioPlugin;
}

// Registering some room events.
const handleRoomEvents = (room) => {
room.onJoined = (payload) => {
console.log('Joined the room room', payload.room);
};
room.onPeerJoined = (payload) => {
console.log('A Peer joined the room', payload.peer);
};
room.onPeerLeft = (payload) => {
console.log('A Peer left the room', payload.peer);
};
room.onStatusChanged = (payload) => {
console.log('The Room status changed', payload.newState);
};
// For all events please refer to the documentation (https://docs.4players.io/voice/web)
}

const startOdin = async function (token) {
// Initializes the web browser plugin (@4players/odin-plugin-web).
await initPlugin();
// Resumes audio, should be called after a user interaction.
audioPlugin.setOutputDevice({}).then();
// Creating a room
room = new Room();
// Registering some room events.
handleRoomEvents(room);
// Joining the room, room is joined once the promise resolves.
await room.join(token);
// Starting audio capturing.
if (!audioInput) {
// Creating an AudioInput. No data is transferred yet.
DeviceManager.createAudioInput()
.then(async (input) => {
audioInput = input;
// Adding the audio input to the room, audio data is transferred now.
await room?.addAudioInput(audioInput);
})
.catch((error) => {
console.error(error);
});
}
}

startOdin('__YOUR TOKEN__').then(() => {
console.log('Started ODIN');
});

Troubleshooting

Contact us through the listed methods below to receive answers to your questions and learn more about ODIN.

Discord

Join our official Discord server to chat with us directly and become a part of the 4Players ODIN community.

Join us on Discord

X (formerly Twitter)

Have a quick question? Tweet us at @ODIN4Players and we’ll help you resolve any issues.

Email

Don’t use Discord or Twitter? Send us an email and we’ll get back to you as soon as possible.