>________________________________
> From: Mateusz Wielgos <wielgosm at gmail.com>
>To: vorbis at xiph.org
>Sent: Wednesday, February 13, 2013 7:41 AM
>Subject: [Vorbis] Vorbis encoding using JavaScript
>
>
>Hello,
>
>
>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. :)
>
>
>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 (https://github.com/kripken/emscripten). From the
docs:
>
>
>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
>_______________________________________________
>Vorbis mailing list
>Vorbis at xiph.org
>http://lists.xiph.org/mailman/listinfo/vorbis
>
>
>
I am just a user of Ogg/Vorbis, so I can't answer your questions
specifically.
Still, have you tested everything in "C" ? I.e. does your
https://github.com/mateusz-/vorbisenc.js/blob/master/encoder_example.c work as
expected ?
Because if it doesn't, JavaScript has nothing to do with your problem.
Regards,
? Sergei.