Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Using JOrbis.jar from JCraft  (Read 5421 times)
0 Members and 1 Guest are viewing this topic.
Offline philfrei
« Posted 2011-06-11 05:44:32 »

I just found a very interesting thread here http://www.java-gaming.org/topics/improving-easyogg/18766/view.html on EasyOgg. Lots of action in trying to get some additional functionality beyond basic playback working. I am wondering what the various participants are now using??

Not knowing about this, I have been modifying ExamplePlayer instead, from here: http://www.jcraft.com/jorbis/tutorial/Tutorial.html, and made an OggVorbisCueWrapper. I think I recreated some of the coding or functions asked for in the above thread. Stuff I've added:
1) clean stop: an isPlaying boolean is checked once every innermost write buffer. Breaks have been added to pop all the way out to the cleanup code, and the isPlaying boolean is checked on the outer loops as well.
2) clean volume changes: a desiredVolume float is checked every frame. Some code has been added to ensure that the very start and end of every play() is ramped quickly to or from zero, to eliminate start/stop clicks that arise from starting or stopping an in progress sound abruptly. (I've heard that there is a way to do this via a filter working directly on the data, but I haven't had a chance to follow up on that yet.)
3) I gone through some rather nutty extremes to make all the JOrbis and JOgg variables stack rather than instance variables, in the hopes of helping out with concurrency problems. Not at all sure if this was misguided or not.  Clueless
4) I've made some outer-level objects that handle concurrency via thread pool use.

An example of this code's use is here, and can be downloaded an run.
www.hexara.com/ffw1.jar

The app is a recreation, in part, of an old composition of mine, pre-MIDI, using asynchronous loops. There is looping, some of it overlapped, some with pauses.

I left the wrapper code in. It isn't my intention to say this is something that someone can pop in and use. I'm showing it more for feedback and ideas and showing some of what I did.The OggVorbisCueWrapper is in an embaressing state, with ExamplePlayer splayed out and about. I left JOgg and JOrbis in, too. I may have tinkered with them, but I'm pretty sure I always put things back the way they were. Not entirely sure. But that was the intent, that the result would work directly with the JCraft code.
 
Some problems remain. The main one is that memory use seems to just climb and climb. At first I thought it was a memory leak, but I'm now thinking it is more an attribute of the garbage collection system or my misuse of how the threads are handled. What makes me think it is NOT a memory leak is that if one looks on JVisualVM.exe (snapshots of the memory), and does multiple Garbage Collections on the app after turning off all the loops, the instance counts of all the likely culprits (in either my code or JCraft code) all go back down to zero or one (or a small expected number that matches what is in the code). But I should say, my experience with profiling tools is rather limited.

If one turns off the sounds and "walks away," it takes a good 10-15 minutes or more for the instance counts to come down. So, I'm wondering how to handle that better. With larger collections of sounds (which I'd like to be able to implement) the memory can climb up to 300MB and start causing playback problems.

But I'm also wondering, if folks have settled on using EasyOgg, or some other OggVorbis wrapper. I'd rather be working with that than knocking my head into known problems. Also, maybe some of the ideas I had for implementing shut down and faders could be added to this code as well, if it hasn't already been done.

Is there interest still? Should I display the source code? I didn't change anything in JOrbis or JOgg, but the JCraft code sure looks weird, having things like public instance arrays. I'm guessing the implementor took the C code given by Xiph and rewrote that almost directly. I'm wondering how bad it would be to go through that exersize once again, but optimize it for game playback use, as well as make the code more OOP, as a possible collaborative project.

Thanks for any input!



"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline tom
« Reply #1 - Posted 2011-06-11 10:54:28 »

I use 3D Sound Engine now.

Offline philfrei
« Reply #2 - Posted 2011-06-12 19:49:26 »

Thanks, Tom.

I note that even Paul doesn't recommend trying to play back more than one Vorbis file at a time. So I am assuming a lot of the resources issues around OggVorbis haven't been solved.

I am kind of bummed. There's a lot of "ambitious" things I want to do, in terms of sound design, using layers and chance methods and the like, but the tech doesn't seem to be there, at least not something that is sitting out as open source.

WAVs are fast, but take up a lot of space in terms of downloading time.
OggVorbis sound fine and are small, but the JOrbis code ties up a lot of resources.

Current thoughts:
1) ditch Ogg and just run (during the game), Vorbis decoding. The Ogg wrapper is just a wrapper for streaming, right? Should be able to extract the underlying Vorbis file pre-compilation and decode that at game time. Xiph says the goal was for Ogg to not add more than a couple % points of cpu load, but maybe the potential savings in memory is significant.

2) look at unpacking sound files at the beginning of the game run, into the faster wav format. I have to learn more about access to temp areas and such, though, especially for Applets.

3) give up the ambitious ideas altogether or just implement them with wav and have them for people who like sound enough to spend the extra time downloading. Figure if the results are fine, the  tech will eventually catch up to work for compressed audio as well.
 Undecided

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 366
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2011-06-13 00:41:12 »

I'm using JOrbis and I seem to be able to decode at least two OGG streams without any troubles. I use 6 buffers of 65kb each for each stream - probably overkill, I think I only really need a third of that - to avoid any glitches. The OggInputStream I use is based on some code from tombr of these parts (it's in SPGL, and easily located in the Revenge of the Titans source code.

Cas Smiley

Offline philfrei
« Reply #4 - Posted 2011-06-13 07:08:31 »

Thanks princec! I'll check it out. I'd LIKE to run more like a dozen at once, if possible, but am probably being too ambitious. But I am also kind of stupid about obstacles and have to ram my head into them a few times. Bloody things up a bit. Slow learner. So much here is new to me.

[EDIT: Ah, I misunderstood. You are converting your OggVorbis files to .wav format and caching them on the client. I started actually looking at the code you generously provided. Nice. I like the management of "single play" cues, too, ending the oldest/lowest priority to make way for new cues. I'm not on the method you are using handling resources via XML yet, but that looks very practical and helpful as well.]

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline CommanderKeith
« Reply #5 - Posted 2011-06-13 15:08:18 »

Wow, it sounds like a major hassle to get compressed sound working ok. Thanks for posting about your findings.

I wonder how the big studios do it, like three rings.

Offline philfrei
« Reply #6 - Posted 2011-06-14 00:25:27 »

@CommanderKeith -- I'm making it harder than it needs to be.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline princec

JGO Kernel


Medals: 366
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2011-06-14 10:05:14 »

Thanks princec! I'll check it out. I'd LIKE to run more like a dozen at once, if possible, but am probably being too ambitious. But I am also kind of stupid about obstacles and have to ram my head into them a few times. Bloody things up a bit. Slow learner. So much here is new to me.

[EDIT: Ah, I misunderstood. You are converting your OggVorbis files to .wav format and caching them on the client. I started actually looking at the code you generously provided. Nice. I like the management of "single play" cues, too, ending the oldest/lowest priority to make way for new cues. I'm not on the method you are using handling resources via XML yet, but that looks very practical and helpful as well.]
Not quite - the actual music is streamed directly from Ogg files. The sound effects are loaded in a single large ogg and decoded directly into memory in one go as ALBuffers where they remain (taking up only a few megs).

Cas Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (35 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (31 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (44 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!