No subject


Tue Jul 31 12:28:58 PDT 2012


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) :
https://github.com/mateusz-/vorbisenc.js/blob/master/encoder_example.c
And, if it helps, here is the corrupted/invalid Ogg file :
https://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&#39;t often program in C so please don&#39;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"https://git=
hub.com/kripken/emscripten" target=3D"_blank">https://github.com/kripken/em=
scripten</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 i=
nto JavaScript, which can be run on the web (or anywhere else JavaScript ca=
n 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 W=
3C web audio api) I pass this data into the JavaScript encoder as command l=
ine arguments. This data is then read, each string converted to a float, an=
d the vorbis_analysis_buffer is filled with this &quot;parsed&quot; data. S=
imilarly, 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 &quot;state&quot; of=
 a stream - either the beginning, middle, or end so I can handle these case=
s 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 e=
ncoding logic is sound? Here is the C source on GitHub (based on libvorbis =
encoder_example.c) :=A0<a href=3D"https://github.com/mateusz-/vorbisenc.js/=
blob/master/encoder_example.c">https://github.com/mateusz-/vorbisenc.js/blo=
b/master/encoder_example.c</a></div>
<div>
And, if it helps, here is the corrupted/invalid Ogg file :=A0<a href=3D"htt=
ps://raw.github.com/mateusz-/vorbisenc.js/master/audio.ogg">https://raw.git=
hub.com/mateusz-/vorbisenc.js/master/audio.ogg</a></div><div><br></div><div=
>
Thank you,</div><div>Mateusz</div>

--0050450162ce51772604d594982a--


More information about the Vorbis mailing list