Java OGG API with concurrent playback

Hello,

I have my own sound system library I use for developing games. We usually use OGG-type sound files, but as I’ve posted on here before, it has issues with playing back two tracks at once in a stream. I shelved the problem back then because we had more important things to do, but I recently came back to it and found that philfrei was right about JOrbis’s concurrency issues. It seems to be an inherent problem with the library itself when it comes to streaming in two files at once.

Anyway, I ended up making my own basic format for handling sound files which works fine enough. That said, I’m still interested in having OGG support in my sound system.

I’ve browsed the internet and haven’t had any luck finding a new OGG API (JOrbis seems to essentially be it, and it hasn’t been updated in years).

Does anyone know of any OGG-supporting APIs out there that is new and won’t have any trouble concurrently reading files? Thanks a lot.

TLDR; I need a JOrbis alternative library that can handle concurrent playback (two tracks at once), preferably with an InputStream tool already built in.

If there’s a thread anywhere on this that I may have missed, please feel free to direct me to it and I’ll be on my way. Hope this isn’t any trouble! Thanks.

LWJGL 3 comes with bindings to stb, which includes stb_vorbis for Ogg Vorbis decoding. You can read the documentation here and explore a simple music player here (demonstrates streaming and seeking).

An stb_vorbis decoder cannot be used from multiple threads, but you can have multiple decoders decoding independently in multiple threads (which is what you need afaict).

Er, I’ve never had any problem playing back two streams with Jorbis…

Cas :slight_smile:

…so if you need any help on it…

Cas :slight_smile:

Do you mean 2 vorbis containers in a single ogg file?

I have my own ogg / vorbis loader and it works with multiple containers in the same stream (Because the is how Theora works which I have another side project ot get working). Depending on what you want to do I can potentially help you fix things as I have a pretty good understanding of the format.

Oh wow, thanks. I’ll definitely look into it. We actually just ported our engine to LWJGL3 so that could probably do the trick.

And this was streaming data from the disk (Not loading it all once)? That’s super interesting. How did you do it? You wouldn’t happen to have it open source somewhere, would you? I was using this OggInputStream object I found on here:

http://home.halden.net/tombr/ogg/ogg.html

I was using two different OggInputStreams as seen above to play two different files at once by streaming them into OpenAL. It causes a crackling noise when you do this. That said, when I used the same method with two WAV files, the sounds streamed fine.

So it seems to be something related to streaming the Ogg files specifically? I’m not sure. Unlike you, I’m definitely not an expert! Lol

Thanks for all the feedback guys. I really do appreciate it.

As it happens my sound “engine” is open sourced and can be found in the Revenge of the Titans source code (http://www.puppygames.net/downloads/RevengeOfTheTitansSource.zip) although that code is maybe a little old and not as nifty as my newer code… anyway, it’s based on LWJGL2 OpenALSoft and JOrbis, and an OggInputStream from here: http://home.halden.net/tombr/ogg/ogg.html (@tombr on these forums)

The basic gist of it is there is a background stream thread that handles all stream reads and decodes (running at priority+3). The data is read in in 64kilobyte chunks; I keep up to 6 chunks in RAM at a time for any stream, as a circular buffer, which I keep as full as possible in case anything comes along that might somehow interrupt sound processing for more than the length of a couple of chunks.

Cas :slight_smile:

I would trust what princec has to say more than philfrei, and that goes double for philfrei of 2013.

I’m not sure I’m necessarily trustworthy but at least that code’s been battle-tested on exactly 779,284 installations (of which 5% Mac, 1% Linux) and it’s doing fine for me :slight_smile:

Cas :slight_smile:

Exact installation numbers courtesy of Steam :wink:

779,284 installations
O Man, it so neat ::slight_smile:

Oh wow, thanks a lot!

Yeah, you guys have given me a lot of content to work with here. I’m off to my batcave now to see what kind of coding concoctions I can come up with lol

Thanks again everyone