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
JS bindings for libopus 1.3.1, ported with emscripten
import*asopusscript_nativefrom"dist/opusscript.js"// 48kHz sampling rate, 20ms frame duration, stereo audio (2 channels)varsamplingRate=48000;varframeDuration=20;varchannels=2;// Optimize encoding for audio. Available applications are VOIP, AUDIO, and RESTRICTED_LOWDELAYvarencoder=newopusscript(samplingRate,channels,opusscript.Application.AUDIO);varframeSize=samplingRate*frameDuration/1000;// Get PCM data from somewhere and encode it into opusvarpcmData=newBuffer(pcmSource);varencodedPacket=encoder.encode(pcmData,frameSize);// Decode the opus packet back into PCMvardecodedPacket=encoder.decode(encodedPacket);// Delete the encoder when finished with it (Emscripten does not automatically call C++ object destructors)encoder.delete();