You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unity Package: Single UPM package for all platforms
C# API: Clean, IDisposable-based managed wrapper
Installation
Via Git URL (Unity Package Manager)
Open Unity Package Manager (Window → Package Manager)
Click "+" → "Add package from git URL"
Enter: https://github.com/trippinc/unityspeex.git
Via OpenUPM
openupm add com.trippinc.unityspeex
Quick Start
Opus Encoding/Decoding
usingTrippInc.UnitySpeex;// Create encodervarencoder=newOpusEncoder(48000,channels:1,OpusApplication.VoIP);encoder.Bitrate=64000;// Encode PCM to Opusshort[]pcmSamples=GetMicrophoneAudio();byte[]outputBuffer=newbyte[4000];intencodedBytes=encoder.Encode(pcmSamples,frameSize:960,outputBuffer);// Create decodervardecoder=newOpusDecoder(48000,channels:1);// Decode Opus to PCMshort[]decodedSamples=newshort[960];intdecodedCount=decoder.Decode(opusPacket,decodedSamples,frameSize:960);// Don't forget to dispose!encoder.Dispose();decoder.Dispose();
Echo Cancellation
usingTrippInc.UnitySpeex;// Create echo canceller// frameSize: samples per frame (160 = 10ms at 16kHz)// filterLengthMs: echo tail length (typically 100-200ms)varaec=newEchoCanceller(frameSize:160,filterLengthMs:100,sampleRate:16000);// Process audio frameshort[]micInput=GetMicrophoneFrame();// Has echo from speakershort[]speakerOutput=GetSpeakerFrame();// What was playedshort[]cleanOutput=newshort[160];aec.Process(micInput,speakerOutput,cleanOutput);// cleanOutput now has echo removedaec.Dispose();
Building from Source
Prerequisites
CMake 3.16+
For Android: Android NDK r26d+
For iOS/macOS: Xcode 14+
For Windows: Visual Studio 2019+ with C++ workload