Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any Chance of Having ogg.js Encode Audio? #2

Closed
shovon opened this issue Aug 8, 2013 · 2 comments
Closed

Any Chance of Having ogg.js Encode Audio? #2

shovon opened this issue Aug 8, 2013 · 2 comments

Comments

@shovon
Copy link

shovon commented Aug 8, 2013

I've been trying, and trying and trying. But I have not been able to write an encoder using libvorbis. I'm specifically interested in libvorbis, because it has the potential to be encoded onto WebM. There is already an image-array-to-WebM encoder, but there is a missing piece to the puzzle: a Vorbis encoder.

So, my issue is, I can't get the code to compile properly. Your code compiles, but the part of libvorbis required to encode audio doesn't seem to get linked, and hence, I get issues of missing function errors. I have pretty much given up, not because I can't encode, but because I have compiler/linker errors.

I was hoping that maybe you might be able to help me out a little.

@devongovett
Copy link
Member

Are there errors compiling or is does it compile without errors, but it's just missing the encoding functions? Sounds like the latter.

Emscripten strips out functions that aren't used, so you have to explicitly tell it what functions to include. In my compile script for vorbis, I set EXPORTED_FUNCTIONS to the list of functions in the vorbis.c wrapper that I wrote. This in turn includes any functions I use from libvorbis.

There are two ways to go about what you want to do. The first is to extend the wrapper to include a VorbisEncode function in C-land, which wraps the vorbis library. The second way is to use the vorbis functions directly from JavaScript. I chose the first way for decoding, and found it much simpler especially with all the pointers that need to get thrown around, which is just not easy in JS/Emscripten land.

So to summarize, I suggest you write a VorbisEncode function in the vorbis.c wrapper to do the actual encoding of some input data that you pass via JavaScript (see vorbis.js for examples), and include it in EXPORTED_FUNCTIONS in the compile script. Let me know if you get it working, would be cool to see a demo. Good luck!

@shovon
Copy link
Author

shovon commented Aug 8, 2013

So to summarize, I suggest you write a VorbisEncode function in the vorbis.c wrapper to do the actual encoding of some input data that you pass via JavaScript (see vorbis.js for examples), and include it in EXPORTED_FUNCTIONS in the compile script.

That's what I did, but it didn't work. In fact, your solution would have only solved the fact that Emscripten can't figure out which subroutine to access when the JavaScript consumer of the API requests it.

My error is different. The compiler only had the declaration (i.e. the function prototype in the .h files), but never did it have the definition of the function (i.e. the function signature and function body in .c files).

However, I did find a solution. I had to tell the compiler which .c file has our missing function definition. This gets rid of our "missing function" error.

But I'm now left with another error. I'm not sure if it's the compiler that isn't able to link the right code, or is it my bad coding skills.

The only thing left for me to do, is take baby steps. For this one project of mine, I was too ambitious, to a point where I have no clue what errors are coming from where.

So anyways, I'm closing this issue, but don't think for a second that I am not interested in figuring out how to encode audio. Especially, if you are also very enthusiastic about finding a solution, then I encourage you to keep posting in this thread.

I just wanted to have a public space to discuss about a potential solution for an audio encoder. GitHub issues seem to be ideal, regardless of the status of a thread (be it open or closed).

Anyways, thanks for your response.

@shovon shovon closed this as completed Aug 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants