Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 6:00 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jul 30, 2012 11:58 pm 
Offline
User avatar

Joined: Mon Jul 30, 2012 11:36 pm
Posts: 4
Location: Minnesota, United States
It took me all day to figure out why my game-in-progress was crashing when I tried playing an .ogg file!

It turns out, if you're playing an .ogg file using the Sound class, it needs to have a minimum length (or perhaps have a minimum file size).

The .ogg file I was using contained a very short blip that I wanted to play when I kill a mob. It consisted of a single 32nd note played at 100bpm. The size of the file was 6.33kb.

The problem went away when I added some reverb to the blip that is undetectable to the ear, but nonetheless lengthens the .ogg file and increases the file size. The modified .ogg file that worked had a size of 12.6kb.

Here is a paraphrase of the code I was using that is relevant:

Code:
public class Mob {

    public Sound mobHit;

    public Mob() throws SlickException {
        ...
        mobHit = new Sound("res/hitmob.ogg");
        ...
    }

    public void collision(){
        ...
        mobHit.play();
        ...
    }
}




And here is the error I was getting after the game crashed on startup:

Code:
...
...
Mon Jul 30 18:30:36 CDT 2012 ERROR:Failure reading in vorbis
Mon Jul 30 18:30:36 CDT 2012 ERROR:null
java.lang.IndexOutOfBoundsException
        at java.io.BufferedInputStream.read(Unknown Source)
   at org.newdawn.slick.openal.OggInputStream.getPageAndPacket(OggInputStream.java:154)
   at org.newdawn.slick.openal.OggInputStream.readPCM(OggInputStream.java:294)
   at org.newdawn.slick.openal.OggInputStream.read(OggInputStream.java:446)
   at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:315)
   at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
   at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
   at org.newdawn.slick.Sound.<init>(Sound.java:58)
   at Slick.Mobs.Mob.<init>(Mob.java:57)
   at Slick.GameStates.LevelOne.init(LevelOne.java:65)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at Slick.Game.main(Game.java:35)
Mon Jul 30 18:30:36 CDT 2012 ERROR:/ by zero
java.lang.ArithmeticException: / by zero
   at org.newdawn.slick.openal.AudioImpl.<init>(AudioImpl.java:38)
   at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:854)
   at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
   at org.newdawn.slick.Sound.<init>(Sound.java:58)
   at Slick.Mobs.Mob.<init>(Mob.java:57)
   at Slick.GameStates.LevelOne.init(LevelOne.java:65)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at Slick.Game.main(Game.java:35)
Mon Jul 30 18:30:36 CDT 2012 ERROR:Failed to load sound: res/hitmobshort.ogg
org.newdawn.slick.SlickException: Failed to load sound: res/hitmobshort.ogg
   at org.newdawn.slick.Sound.<init>(Sound.java:70)
   at Slick.Mobs.Mob.<init>(Mob.java:57)
   at Slick.GameStates.LevelOne.init(LevelOne.java:65)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at Slick.Game.main(Game.java:35)
AL lib: FreeContext: (031826B8) Deleting 64 Source(s)

_________________
-Michael


Top
 Profile  
 
PostPosted: Tue Aug 07, 2012 5:13 am 
Offline
Regular

Joined: Tue Aug 23, 2011 8:19 am
Posts: 111
I posted something similar on the LWJGL forum: http://lwjgl.org/forum/index.php/topic,4647.0.html

I also sent an email to the creators of jogg/jorbis about the problem, but they never responded.

Is your short sound file a stereo file (as opposed to mono)? If so, then it's the exact same problem I was having. If you change the file to mono, it should play fine (but then it causes an issue with my headset, which is the main topic of the thread I linked to).

_________________
My indie games: http://cmagames.webs.com


Top
 Profile  
 
PostPosted: Fri Mar 22, 2013 2:19 pm 
Offline

Joined: Fri Mar 22, 2013 2:15 pm
Posts: 2
Just experienced this and thought I'd put some more data in for people trying to avoid it:

Length of time the clip lasts for is not relevant, so adding silence at the end doesn't help.
My original file was 7.0KB, and caused the problem. Adding a second of silence barely changed the file size (guess silence compresses really well! :) ). Saving with maximum quality increased it to 9.2KB, which works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group