Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java OGG API with concurrent playback  (Read 48421 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid
« Posted 2016-04-17 08:48:02 »

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.

it just werks
Online Spasi
« Reply #1 - Posted 2016-04-17 09:44:40 »

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).
Offline princec

« JGO Spiffy Duke »


Medals: 1136
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2016-04-17 10:19:05 »

Er, I've never had any problem playing back two streams with Jorbis...

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 1136
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2016-04-17 13:40:08 »

...so if you need any help on it....

Cas Smiley

Offline ziozio
« Reply #4 - Posted 2016-04-17 20:02:13 »

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.
Offline SkyAphid
« Reply #5 - Posted 2016-04-18 05:22:12 »

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).

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

Er, I've never had any problem playing back two streams with Jorbis...

Cas Smiley

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

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.

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.

it just werks
Offline princec

« JGO Spiffy Duke »


Medals: 1136
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2016-04-18 08:19:06 »

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 Smiley

Offline philfrei
« Reply #7 - Posted 2016-04-18 09:29:06 »

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

music and music apps: http://adonax.com
Offline princec

« JGO Spiffy Duke »


Medals: 1136
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2016-04-18 10:28:42 »

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 Smiley

Cas Smiley

<edit>Exact installation numbers courtesy of Steam Wink

Offline Icecore
« Reply #9 - Posted 2016-04-18 10:54:40 »

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 Smiley
779,284 installations
O Man, it so neat  Roll Eyes

Last known State: Reassembled in Cyberspace
End Transmission....
..
.
Journey began Now)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SkyAphid
« Reply #10 - Posted 2016-04-19 03:46:02 »

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 Smiley

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

it just werks
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (463 views)
2019-09-04 15:33:17

hadezbladez (5322 views)
2018-11-16 13:46:03

hadezbladez (2249 views)
2018-11-16 13:41:33

hadezbladez (5597 views)
2018-11-16 13:35:35

hadezbladez (1164 views)
2018-11-16 13:32:03

EgonOlsen (4600 views)
2018-06-10 19:43:48

EgonOlsen (5474 views)
2018-06-10 19:43:44

EgonOlsen (3138 views)
2018-06-10 19:43:20

DesertCoockie (4033 views)
2018-05-13 18:23:11

nelsongames (4782 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!