Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run). I was able to successfully build libogg, libvorbis and libvorbis examples using this tool and generate valid JavaScript (hopefully working as intended also...). In JavaScript, once I obtain the left and right channel audio data (using W3C web audio api) I pass this data into the JavaScript encoder as command line arguments. This data is then read, each string converted to a float, and the vorbis_analysis_buffer is filled with this "parsed" data. Similarly, I pass the quality as an argument and run vorbis_encode_init_vbr accordingly. One last thing that I pass in is a "state" of a stream - either the beginning, middle, or end so I can handle these cases differently (for example, at the start of the stream I set all necessary headers). The generated file, however, does not seem to be valid and does not play. Could somebody verify that my encoding logic is sound? Here is the C source on GitHub (based on libvorbis encoder_example.c) : github.com/mateusz-/vorbisenc.js/blob/master/encoder_example.c And, if it helps, here is the corrupted/invalid Ogg file : raw.github.com/mateusz-/vorbisenc.js/master/audio.ogg Thank you, Mateusz --0050450162ce51772604d594982a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,<div><br></div><div>First of all, I am a complete newblet to anything dealing with audio (a lot of the vocabulary is still rather mysterious to me). I also don't often program in C so please don't throw too many stones if my workflow is less than ideal. :)</div> <div><br></div><div>I would like to port the vorbis encoder to JavaScript. Instead of porting everything by hand from ground up, which would take who-knows-how-long, I am using a tool called emscripten (<a href=3D"github.com/kripken/emscripten" target=3D"_blank">github.com/kripken/emscripten</a>). From the docs:</div> <div><br></div><div>Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).</div> <div><br></div><div>I was able to successfully build libogg, libvorbis and libvorbis examples using this tool and generate valid JavaScript (hopefully working as intended also...).</div><div><br></div><div> In JavaScript, once I obtain the left and right channel audio data (using W3C web audio api) I pass this data into the JavaScript encoder as command line arguments. This data is then read, each string converted to a float, and the vorbis_analysis_buffer is filled with this "parsed" data. Similarly, I pass the quality as an argument and run vorbis_encode_init_vbr accordingly.</div> <div><br></div><div>One last thing that I pass in is a "state" of a stream - either the beginning, middle, or end so I can handle these cases differently (for example, at the start of the stream I set all necessary headers).</div> <div><br></div><div>The generated file, however, does not seem to be valid and does not play.</div><div><br></div><div>Could somebody verify that my encoding logic is sound? Here is the C source on GitHub (based on libvorbis encoder_example.c) :=A0<a href=3D"github.com/mateusz-/vorbisenc.js/blob/master/encoder_example.c">github.com/mateusz-/vorbisenc.js/blob/master/encoder_example.c</a></div> <div> And, if it helps, here is the corrupted/invalid Ogg file :=A0<a href=3D"raw.github.com/mateusz-/vorbisenc.js/master/audio.ogg">raw.github.com/mateusz-/vorbisenc.js/master/audio.ogg</a></div><div><br></div><div> Thank you,</div><div>Mateusz</div> --0050450162ce51772604d594982a--