export declare const Application: {
    readonly Voip: 2048;
    readonly Audio: 2049;
    readonly RestrictedLowDelay: 2051;
};
export declare const Signal: {
    readonly Auto: -1000;
    readonly Voice: 3001;
    readonly Music: 3002;
};
export declare const Bitrate: {
    readonly Auto: -1000;
    readonly Max: -1;
};
export declare const Bandwidth: {
    readonly Narrowband: 1101;
    readonly Mediumband: 1102;
    readonly Wideband: 1103;
    readonly Superwideband: 1104;
    readonly Fullband: 1105;
};
export declare const EncoderCtl: {
    readonly SetApplication: 4000;
    readonly SetBitrate: 4002;
    readonly SetMaxBandwidth: 4004;
    readonly SetVbr: 4006;
    readonly SetBandwidth: 4008;
    readonly SetComplexity: 4010;
    readonly SetInBandFec: 4012;
    readonly SetPacketLossPercent: 4014;
    readonly SetDtx: 4016;
    readonly SetVbrConstraint: 4020;
    readonly SetForceChannels: 4022;
    readonly SetSignal: 4024;
    readonly SetLsbDepth: 4036;
    readonly SetExpertFrameDuration: 4040;
    readonly SetPredictionDisabled: 4042;
    readonly SetPhaseInversionDisabled: 4046;
    readonly SetUseSmpl: 4050;
    readonly SetEncHpCutoff: 4052;
    readonly SetSecondaryComplexity: 4054;
    readonly SetSecondaryBitrate: 4056;
    readonly SetMlowSubframeImp: 4060;
    readonly SetMlowUseSpActFlat: 4062;
    readonly SetMlowVadNlUpdSpeed: 4064;
    readonly SetMlowVadNonBinary: 4066;
    readonly SetMlowVadHpSharpness: 4068;
    readonly SetMlowUseFecRateComp: 4070;
};
/**
 * Which coding mode a packet's TOC selects. The first byte decides: bits 7-6
 * equal to `0b11` mean CELT, anything else means the native SMPL/MLow layout.
 * This is the field that tells a WhatsApp-style MLow packet apart from a CELT
 * fallback.
 */
export declare const MlowMode: {
    readonly Celt: 3;
    readonly Smpl: 4;
};
export declare const DecoderCtl: {
    readonly SetGain: 4034;
    readonly SetPhaseInversionDisabled: 4046;
    readonly SetUseLpcPostfilter: 4058;
    readonly SetUseSmpl: 4050;
};
export type Application = (typeof Application)[keyof typeof Application];
export type Signal = (typeof Signal)[keyof typeof Signal];
export type Bitrate = number | "auto" | "max";
export type Bandwidth = (typeof Bandwidth)[keyof typeof Bandwidth];
export type SampleRate = 8000 | 12000 | 16000 | 24000 | 48000;
export type ChannelCount = 1 | 2;
export type CodecOptions = {
    channels?: ChannelCount;
    sampleRate?: SampleRate;
};
export type EncoderOptions = CodecOptions & {
    application?: Application;
    bitrate?: Bitrate;
    complexity?: number;
    dtx?: boolean;
    fec?: boolean;
    frameSize?: number;
    maxBandwidth?: Bandwidth;
    packetLossPercent?: number;
    signal?: Signal;
    useSmpl?: boolean;
    vbr?: boolean;
    vbrConstraint?: boolean;
};
export type DecoderOptions = CodecOptions & {
    /**
     * The MLow Companion's weights: the DNNw container the WhatsApp client
     * fetches at runtime (`mlow_companion_v1`). Not shipped with this library;
     * pass the bytes you have. Attaches the neural post-filter the client runs
     * inside its decoder, on 20 ms wideband mono MLow frames; other frames
     * decode as before. Requires `useSmpl: true`. The bytes are copied, so the
     * array can be released once the decoder exists.
     */
    companionModel?: Uint8Array;
    maxFrameSize?: number;
    /**
     * The codec's classical LPC postfilter. `true` enables it at every rate;
     * `false` disables it at every rate, which is what the WhatsApp client does.
     * Unset leaves the codec default: off for wideband, on for super-wideband.
     */
    useLpcPostfilter?: boolean;
    useSmpl?: boolean;
};
export type DecodeOptions = {
    decodeFec?: boolean;
    frameSize?: number;
    maxFrameSize?: number;
};
export type RepacketizerOptions = {
    maxPacketBytes?: number;
    useMlow?: boolean;
};
export type PackOptions = {
    maxPacketBytes?: number;
};
export type EncodeOptions = {
    frameSize?: number;
    maxPacketBytes?: number;
};
export type PacketInfoOptions = {
    sampleRate?: SampleRate;
};
export type OpusPacketInfo = {
    readonly bandwidth: Bandwidth;
    readonly channels: ChannelCount;
    readonly durationMs: number;
    readonly frames: number;
    readonly samples: number;
    readonly samplesPerFrame: number;
    readonly sampleRate: SampleRate;
};
export type MlowMode = (typeof MlowMode)[keyof typeof MlowMode];
export type MlowPacketToc = {
    /**
     * Compare against {@link MlowMode}: `MlowMode.Smpl` for a native MLow packet,
     * `MlowMode.Celt` otherwise. Stays `number` so the field keeps accepting any
     * future mode the codec adds.
     */
    readonly mode: number;
    readonly bandwidth: number;
    readonly samplesPerFrame: number;
    readonly stereo: number;
};
export type MlowPacketInfo = OpusPacketInfo & {
    readonly hasVadFlag: boolean;
    readonly hasFecContent: boolean;
    readonly toc: MlowPacketToc;
};
export type OpusEncoderHandle = {
    readonly application: Application;
    readonly channels: ChannelCount;
    readonly frameSize: number;
    readonly sampleRate: SampleRate;
    encode(pcm: Int16Array | Uint8Array, options?: EncodeOptions): Uint8Array;
    encodeFloat(pcm: Float32Array, options?: EncodeOptions): Uint8Array;
    encodeFrames(frames: readonly (Int16Array | Uint8Array)[], options?: EncodeOptions): Uint8Array[];
    encodeFloatFrames(frames: readonly Float32Array[], options?: EncodeOptions): Uint8Array[];
    /**
     * Encodes the redundant (RED) copy of the frame just passed to {@link encode}.
     * Call it right after `encode()` on the same frame. Requires `useSmpl` plus a
     * secondary bitrate: see `setSecondaryBitrate`.
     */
    /**
     * Encodes into a caller-owned buffer and returns the byte count, allocating
     * nothing. Use it when per-frame garbage matters; `encode()` is the same work
     * plus a fresh `Uint8Array` each call.
     */
    encodeInto(pcm: Int16Array | Uint8Array, target: Uint8Array, options?: EncodeOptions): number;
    encodeFloatInto(pcm: Float32Array, target: Uint8Array, options?: EncodeOptions): number;
    encodeSecondary(options?: EncodeOptions): Uint8Array;
    setSecondaryBitrate(bitrate: number): void;
    setSecondaryComplexity(complexity: number): void;
    readonly useSmpl: boolean;
    encoderCtl(request: number, value: number): void;
    free(): void;
    getBitrate(): number;
    getInDtx(): boolean;
    getLookahead(): number;
    setBitrate(bitrate: Bitrate): void;
    setComplexity(complexity: number): void;
    setDtx(enabled: boolean): void;
    setFec(enabled: boolean): void;
    setMaxBandwidth(bandwidth: Bandwidth): void;
    setPacketLossPercent(percentage: number): void;
    setSignal(signal: Signal): void;
    setVbr(enabled: boolean): void;
    setVbrConstraint(enabled: boolean): void;
    [Symbol.dispose](): void;
};
export type MlowRepacketizerHandle = {
    readonly useMlow: boolean;
    /** Packs frames into one multiframe packet in a single WASM call. */
    pack(frames: readonly Uint8Array[], options?: PackOptions): Uint8Array;
    /** Clears the queued frames so the state can be reused. */
    reset(): void;
    /** Queues one frame for the next {@link out} call. */
    add(frame: Uint8Array): void;
    /** Number of frames queued so far. */
    getFrameCount(): number;
    /** Emits every queued frame as one packet. */
    out(options?: PackOptions): Uint8Array;
    /** Emits `[begin, end)` of the queued frames as one packet. */
    outRange(begin: number, end: number, options?: PackOptions): Uint8Array;
    free(): void;
    [Symbol.dispose](): void;
};
export type OpusDecoderHandle = {
    readonly channels: ChannelCount;
    readonly maxFrameSize: number;
    readonly sampleRate: SampleRate;
    decode(packet: Uint8Array | null, options?: DecodeOptions): Int16Array;
    decodeFloat(packet: Uint8Array | null, options?: DecodeOptions): Float32Array;
    /**
     * Decodes into a caller-owned buffer and returns the sample count (per
     * channel), allocating nothing. `decode()` is the same work plus a fresh
     * `Int16Array` each call: at 48 kHz stereo that is 3,840 bytes per frame.
     */
    decodeInto(target: Int16Array, packet: Uint8Array | null, options?: DecodeOptions): number;
    decodeFloatInto(target: Float32Array, packet: Uint8Array | null, options?: DecodeOptions): number;
    decodeFrames(packets: readonly (Uint8Array | null)[], options?: DecodeOptions): Int16Array[];
    decodeFloatFrames(packets: readonly (Uint8Array | null)[], options?: DecodeOptions): Float32Array[];
    readonly useSmpl: boolean;
    decodePacketLoss(frameSize?: number): Int16Array;
    decodePacketLossFloat(frameSize?: number): Float32Array;
    decoderCtl(request: number, value: number): void;
    /** Whether an MLow Companion is attached. */
    readonly hasCompanion: boolean;
    /**
     * Attaches the MLow Companion built from `model`, replacing one already
     * attached, or detaches it with `null`. Only MLow (SMPL) streams reach it.
     * A replaced Companion starts from a clean state.
     */
    setCompanionModel(model: Uint8Array | null): void;
    /**
     * Clears the attached Companion's recurrent state and filter memories.
     * Call it where the stream restarts; decoding carries on otherwise.
     */
    resetCompanion(): void;
    free(): void;
    [Symbol.dispose](): void;
};
export declare function opusGlobalCreate(): Promise<void>;
export declare function opusGlobalFree(): Promise<void>;
export declare function loadLibopus(): Promise<{
    version: string;
}>;
export declare function createEncoder(options?: EncoderOptions): Promise<OpusEncoderHandle>;
/**
 * Creates a repacketizer that packs several MLow frames into one multiframe
 * packet: the framing WhatsApp calls use (3×20 ms per packet is typical).
 * `opus_encode` does not do this on the SMPL path, so packing is the only way
 * to produce interoperable multiframe packets.
 */
export declare function createRepacketizer(options?: RepacketizerOptions): Promise<MlowRepacketizerHandle>;
export declare function createDecoder(options?: DecoderOptions): Promise<OpusDecoderHandle>;
export declare function getPacketInfo(packet: Uint8Array, options?: PacketInfoOptions): Promise<OpusPacketInfo>;
export declare function getMlowPacketInfo(packet: Uint8Array, options?: PacketInfoOptions): Promise<MlowPacketInfo>;
export declare class OpusError extends Error {
    readonly code: number;
    readonly codeName: OpusErrorCodeName | undefined;
    readonly operation: string | undefined;
    constructor(code: number, message: string, operation?: string);
}
/**
 * The MLow Companion rejected its model. Its codes are its own and overlap
 * Opus's numerically, which is why this is not an {@link OpusError}.
 */
export declare class CompanionError extends Error {
    readonly code: number;
    readonly codeName: CompanionErrorCodeName | undefined;
    constructor(code: number);
}
/** `COMPANION_*` in native/companion.h. */
export declare const CompanionErrorCode: {
    readonly BadArg: -1;
    readonly AllocFail: -2;
    readonly BadModel: -3;
    readonly MissingTensor: -4;
};
export type CompanionErrorCodeName = keyof typeof CompanionErrorCode;
export declare const OpusErrorCode: {
    readonly BadArg: -1;
    readonly BufferTooSmall: -2;
    readonly InternalError: -3;
    readonly InvalidPacket: -4;
    readonly Unimplemented: -5;
    readonly InvalidState: -6;
    readonly AllocFail: -7;
};
export type OpusErrorCodeName = keyof typeof OpusErrorCode;
export declare function isOpusError(error: unknown): error is OpusError;
//# sourceMappingURL=index.d.ts.map