Within that link, one of the answers is this:
“I guess Eclipse has problems with WAV files, if they’re too big, because my Music.wav which was around 7mb wouldn’t work, but my Soundeffect.wav which was less than 1mb worked fine.”
Is this still true or am I doing something wrong? I feel like, at least with a program as big and important as Eclipse, that shouldn’t happen? But I’m probably wrong.
And if it is true, how come the music files play fine in Eclipse but not the runnable jar (if it is indeed an Eclipse problem)? I would think it would be the other way around. That seems like it would be a JVM problem of some sort, unless Eclipse f**ks it up during the export.
Edit: I can post the code if it helps…and also I’m not getting any errors running the jar from the command line that have anything to do with loading or playing the music files.
No problem about posting questions. This forum could do with a lot more of them!
I’ve only had a little experience with libgdx’s libraries for handling audio, when I was first looking at what would be involved in writing a wrapper for my audio library. I’m assuming that you are NOT using javax.sound.sampled.SourceDataLine, which would normally be the first choice for the playback of files that are too large to hold in memory.
If you were using javax.sound.sampled.Clip, I’d ask if you were reloading the audio data for each play back. Lots of programmers new to audio do this, not realizing that the entire file has to load before the sound will start playing, and for large files the lag can be considerable.
Can you show the code for playback? Is everything identical except the size of the files?
I doubt this is an Eclipse issue. But if you are storing the SFX and the longer cues in different places, then that would be worth exploring. There are times when one can play audio from within Eclipse but not within a jar, due to how the files are addressed and where they are located.
As far as using mp3 or ogg, I think it was @nsigma who set up a collection of useful utils here. But they’d probably require a bit of fussing to get them to run over libgdx. He’ll probably know more about that.
Where are the sound files stored? How are you addressing those files? Are they being addressed by their File addresses or by URL? File addresses don’t work in jars, but they will work in Eclipse. You should be using URLs.
Another thought, is it possible to inquire programmatically about the length of the various cues after they are loaded? I’m wanting to verify that the files actually get loaded.
Another thought, it might be an interesting test to take the largest SFX file and load it as a musical cue, and the shortest musical cue and load it as an SFX.