Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Simple Lossy Audio?  (Read 3186 times)
0 Members and 1 Guest are viewing this topic.
Offline ShannonSmith
« Posted 2010-10-07 22:15:45 »

I am after a solution for a simple, easy to integrate lossy audio format for bundling audio assets with games. I am yet to find a solution and hoping that one exits.

What doesn't work for me:
Paul's 3D Sound Engine - I am not looking for a complete sound engine JUST a lossy audio format/decoder.
jorbis/j-ogg - Both are buggy as hell and have terrible API's that are impossible to integrate elegantly (see how nasty the PulpCore/JME/GTGE integration is).

Ideally:
Could convert wave files to said format with a tool such as Audacity and have an API such as:
1  
2  
audioFile.getTotalSamples();
audioFile.decodeSamples(int offset, byte[] dest, int destOffset, int sampleCount);


Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2010-10-07 22:45:39 »

...what's wrong with Jorbis? It's been working for me for the last 8 years. Admittedly I don't stray too far from the beaten path in wave formats but then why would anyone really need to?

Cas Smiley

Offline ShannonSmith
« Reply #2 - Posted 2010-10-07 23:05:22 »

Given somefile.ogg, can you post the code using jorbis to decode to pcm samples 100-200 into a byte array?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2010-10-07 23:15:01 »

Hell no, I just either decode the whole thing or stream it. Hm and as you have to decode it in order to know where the samples are actually going to be I suppose that's half of the problem solved already. OGG doesn't have indices does it?

Cas Smiley

Offline ShannonSmith
« Reply #4 - Posted 2010-10-07 23:19:35 »

Ogg is great for streaming audio but that's not really what I want. Also completely decoding a longish music track into memory means ~60mb heap space wasted.
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2010-10-07 23:59:46 »

I think you're trying to find the solution for something that isn't a problem.

Firstly - yes, Ogg is great for streaming music. So why would you decode an entire track in to the heap?
Secondly - pack all your sound effects into a single Ogg (or two, if you have both stereo and mono effects), and make a note of their PCM byte offsets. Stream decode that Ogg at startup, chopping into bits according to your PCM byte index file, uploading each PCM effect to OpenAL (or whatever). Let OpenAL or whatever manage the memory for you - which it will do, perfectly nicely, outside of the Java heap. Your sound effects will take up a trivial amount of ram.

Cas Smiley

Offline ShannonSmith
« Reply #6 - Posted 2010-10-08 15:26:04 »

I'm actually look for an applet (sandbox) solution so OpenAL is out. This is also why I don't want to 60 megs on the heap given you can't change the applet sandbox heap size without a security dialog.

I could do this with Jorbis and a fair amount of glue code it's just I hate complicated solutions to what I perceive to be a simple problem and I was hoping there was a simple solution but it looks unlikely.
Offline zammbi

JGO Coder


Medals: 4



« Reply #7 - Posted 2010-10-08 15:37:11 »

Why not 3D Sound Engine? You can grab only the codecs you need to keep it small. It doesn't need to be signed.

Current project - Rename and Sort
Offline Roquen
« Reply #8 - Posted 2010-10-08 15:40:45 »

Good audio compression is hard (and a patent minefield).  What kind of compression ratios are you looking for? What sound quality?  If you want something that doesn't sound lossy..make your life easy and use an existing codec.
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2010-10-08 16:07:00 »

It ain't that hard and you don't have to use OpenAL as the rendering backend, just stream the data to JavaSound. At the end of the day if you want to use compressed sound you have to realise it's Not Totally Simple In Java.

Cas Smiley

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

Senior Member


Medals: 12


Staff Sergeant


« Reply #10 - Posted 2010-10-08 19:54:31 »

Why not 3D Sound Engine? You can grab only the codecs you need to keep it small. It doesn't need to be signed.
In this case, since you are only after a decoder and not a complete sound engine, you could just use my CodecJOrbis or CodecJOgg plug-ins stand-alone (without the rest of the SoundSystem).  Grab the ICodec and SoundBuffer classes from the core SoundSystem library (or make a couple of small modifications to the CodecJOrbis or CodecJOgg sourcecode) and it should be good to go without the rest of the engine.  However, it is not capable of decoding "pcm samples 100-200 into a byte array" as you would like to do.  The only way to do something like that I am aware of is to "remember" the desired offset when you create the .ogg file, as princec suggested.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline Momoko_Fan

Junior Member


Medals: 2



« Reply #11 - Posted 2010-10-09 00:39:43 »

jME3 has a class that uses J-Ogg to decode an audio file, no streaming, no extra layers, etc. The result is an InputStream that gives you data in signed short format.
See here: http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/jogg/com/jme3/audio/plugins/OGGLoader.java
So far any file I threw at it worked. I use mostly aoTuV and oggenc2 for encoding, as they have the best compression and speed.
Offline sunet2000

Senior Newbie




I want my mumart account back!


« Reply #12 - Posted 2010-10-14 18:39:19 »

Might 352kbps ADPCM be good enough? I've got an implementation with an API that's pretty much exactly what you're looking for:

https://sites.google.com/site/mumart/home/imaadpcm

Cheers,
Martin
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.

Dwinin (29 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (76 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (35 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!