Thanks for sharing this. I love the simplicity.
Just a quick nooby question if I may. I'm just working on sound for my first game, and decided to use your library to make things easier. However I keep getting the following exception when I attempt to load a new sound. Here's the callstack:
1 2 3 4 5 6 7 8
| Exception in thread "Thread-4" java.lang.NegativeArraySizeException at kuusisto.tinysound.TinySound.readAllBytesTwoChannel(TinySound.java:412) at kuusisto.tinysound.TinySound.readAllBytes(TinySound.java:365) at kuusisto.tinysound.TinySound.loadSound(TinySound.java:335) at kuusisto.tinysound.TinySound.loadSound(TinySound.java:310) at brickout6.Game.LoadContent(Game.java:95) at brickout6.Game.access$100(Game.java:28) at brickout6.Game$1.run(Game.java:61) |
and the code fragment it fails at:
1 2 3 4 5
| private static byte[][] readAllBytesTwoChannel(AudioInputStream stream) { int numBytesPerChannel = (int)stream.getFrameLength() * (stream.getFormat().getFrameSize() / 2); byte[] left = new byte[numBytesPerChannel]; |
Now, I get that a NegativeArraySizeException is telling me that numBytesPerChannel is returning an invalid array index. but I'm not quite sure why I should be getting it in this case? Checking the code, it performs multiple data validity/null checks on the loaded file prior to reaching this line so if there was something wrong with say, the path to the file, or the integrity of the file, surely this would be flagged sooner by the built-in error handling?
Sorry for the nooby question as I'm very much a beginner at all this. Any idea what's going on here?