xiph / xiph/opus

Crackled Audio - Web Assembly Compilation ( WASM )

Open
#272 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

Hi ,
We have compiled opus into wasm and trying to decode an audio in browser through wasm and play it . Opus decoder produces distorted/bad audio .

Here are the steps to compile opus into wasm .

./autogen.sh

emconfigure ./configure --prefix=/home/local/ZOHOCORP/praveen-10261/opus-wasm/opus_libwasm/opus/opus/ --disable-rtcd --disable-intrinsics --disable-shared   --enable-static  --disable-stack-protector --disable-hardening

emmake make

emmake make install

Below is the C Wrapper to call opus API's:

#include <opus/opus.h>
#include <emscripten.h>
#include <stdlib.h>

void *decoder;

void *malloc_(int size){
      return malloc(size);
}

int opus_decoder_create_(int sample_rate , int channels){
    int err;

    decoder = opus_decoder_create(sample_rate,channels,&err);

    if(err != OPUS_OK){
       return -1; 
    }

    return 1;
}

int opus_decode_(void *encoded_data,int data_len , float *decoded_data,int max_size){

    return opus_decode_float(decoder,encoded_data,data_len,decoded_data,max_size,0);
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Emscripten configure and make commands and the C wrapper around opus_decoder_create and opus_decode_float. Reproduce the browser decode and playback path, then compare the decoded output with a known-good native result to locate the source of the distortion. Done means identifying and correcting the WASM decoding issue, with audio playback no longer distorted.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, wasm
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.