import { OdinAPMSettings, OdinRoom } from "./odin.room"; /** * Represents a decoded audio buffer (from audio-decode library). */ export interface AudioBuffer { sampleRate: number; numberOfChannels: number; duration: number; length: number; getChannelData(channel: number): Float32Array; } /** * The OdinMedia class represents a local audio stream for sending audio to the room. * Don't create OdinMedia instances directly, use `createAudioStream` from OdinRoom instead. * * This wrapper closely follows the core ODIN SDK pattern: * 1. Create audio stream: `media = room.createAudioStream(48000, 2)` * 2. Set server-assigned media ID: `media.setMediaId(mediaIds[0])` // From Joined event * 3. Send audio chunks: `media.sendAudioData(chunk)` // 20ms chunks recommended * 4. When done: `media.close()` * * Or use the convenience API for file playback: * await media.sendMP3('./file.mp3'); // Auto handles everything * await media.sendWAV('./file.wav'); * await media.sendBuffer(audioBuffer); */ export declare class OdinMedia { /** * Creates a new instance of a media object. * Don't create OdinMedia directly, use `createAudioStream` from OdinRoom instead. * @param room - The room to add the media to. * @param sampleRate - The sample rate of the audio stream (between 8000 and 48000) * @param channelCount - The number of channels of the audio stream (1 or 2) * @param options - Optional configuration options for Odin Audio Processing Module (APM). */ constructor(room: OdinRoom, sampleRate: number, channelCount: number, options?: OdinAPMSettings); /** * Sets the server-assigned media ID. * Must be called before sendAudioData() with an ID from the Joined event's mediaIds array. * @param mediaId - The media ID from Joined event */ setMediaId(mediaId: number): void; /** * Closes the local audio stream and releases resources. * After calling this, the media stream cannot be used. */ close(): void; /** * Sends audio data to the room. * Data must be a 32-bit float array with samples between -1 and 1. * Audio data should be sent in regular intervals (20ms chunks recommended). * @param data - A 32-bit float array containing the audio data. */ sendAudioData(data: Float32Array): void; /** * Send an MP3 file with automatic decoding and real-time streaming. * Handles all setup (media ID, StartMedia RPC, timing) automatically. * * @param filePath - Path to the MP3 file * @returns Promise that resolves when audio streaming is complete */ sendMP3(filePath: string): Promise; /** * Send a WAV file with automatic decoding and real-time streaming. * Handles all setup (media ID, StartMedia RPC, timing) automatically. * * @param filePath - Path to the WAV file * @returns Promise that resolves when audio streaming is complete */ sendWAV(filePath: string): Promise; /** * Send decoded audio with real-time streaming. * Handles all setup (media ID, StartMedia RPC, timing) automatically. * * @param audioBuffer - Decoded audio buffer (from audio-decode library) * @returns Promise that resolves when audio streaming is complete */ sendBuffer(audioBuffer: AudioBuffer): Promise; /** * Gets the ID of the media. * @returns The ID of the media, or null if closed. */ get id(): number | null; /** * Checks if this media stream has been closed. * @returns True if the stream is closed and can no longer be used. */ get closed(): boolean; }