I downloaded it twice, but both times the jar appeared to be corrupted. Regardlesss, I was going to include the jorbis, tritonus-share and vorbisspi libraries separately for the sake of being able to select different versions of each.

I'm working on trying to add sound to my game and i'm casting everything just as it's written in the example. But when I create the sound with the method "kuusisto.tinysound.Sound sound = TinySound.loadSound(filename);" and then call it with "sound.play();" it keeps saying that 'sound' is null and i keep getting a nullpointerexception. Any help with this? Otherwise, everything is beautifully simple.

The loadSound() function returns null if it failed to load. It's possibly a format thing, but there should be an error message printed to the terminal. I guess I should say that it will also return null if you haven't yet called the init() function.

The loadSound() function returns null if it failed to load. It's possibly a format thing, but there should be an error message printed to the terminal. I guess I should say that it will also return null if you haven't yet called the init() function.

i call the init() function in the very beginning of the program. do i have to call it in the beginning of that same method or class? As for an error message, all i got was the standard nullpointerexcepiton error.

That's probably it. It looks like I don't print a message if the InputStream that it opens is null. Make sure your sound file is on the classpath. Also, you should only specify the file name if you use the load function that takes a String. If you want to load a sound using a path to the file, you need to use the function that takes a File object.

Are we getting into the InputStream issues with audio again? I haven't looked at your code, but if you are using a classLoader and getResourceAsStream() method, then you are probably returning an InputStream, and InputStreams often need to have mark/reset capabilities or they throw exceptions, and audio files (e.g. wav files) often don't support this! And part of the problem is in part that it does work under some conditions, but is much less likely to work going forward. ra4king helped me figure out this problem when code of mine worked for his java 1.6, but bombed on his java 7.

If you need to get an AudioInputStream, can I recommend that you use the classLoader to return a URL of a String for your filename? I suspect your code will run more universally that way.

This bypasses the use of an InputStream, circumventing the need for mark/reset capabilities on the file.

I hope I haven't "gone off" on something totally extraneous. Apologies if I have. But when I hear stuff about InputStreams when loading audio, I can't help but think it is this problem. It has been showing up again and again--isn't really well known yet.

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables

It's best to use getClass().getClassLoader().getResourceAsStream(String), where the String does not start with a forward slash and is relative to the root of the project.

that's probably what i forgot, i was simply putting the source in as a string.

I'm sure you didn't forget anything. They're suggesting that TinySound should do this under the hood.

I'm pretty sure it doesn't have to do with mark/reset capabilities. I don't use those anywhere in my code and I can't find anywhere in the documentation that says an InputStream needs to support them to open AudioInputStreams. I would assume that the AudioSystem.getAudioInputStream() function taking a URL opens an InputStream under the hood anyway. The function that takes a String looks like this:

/*** Load a Music by a resource name. The resource must be on the classpath* for this to work.* @param name name of the Music resource* @return Music resource as specified, null if not found/loaded*/publicstaticMusicloadMusic(Stringname) {//check if the system is initializedif (!TinySound.inited) {System.err.println("TinySound not initialized!");returnnull; }//check for failureif (name == null) {returnnull; }//check for correct namingif (!name.startsWith("/")) {name = "/" + name; }InputStreamstream = TinySound.class.getResourceAsStream(name);//check for failure to find resourceif (stream == null) {System.err.println("Unable to find resource " + name + "!");returnnull; }returnTinySound.loadMusic(stream);}

I'm reasonably confident he just didn't have the audio file on his classpath or some such. I've added that null check on the stream with a message last night.

The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream's read pointer to its original position. If the input stream does not support these operation, this method may fail with an IOException

I've opened an issue on the repo and will try to get it using URLs instead ASAP. This is system dependent, but it shouldn't be terribly difficult to change.

I went ahead and switched it to use URLs as philfrei suggested. Another option would have been to wrap all InputStreams with BufferedInputStreams, but I like the URL solution. See if that works for you cubemaster21.

Yeah that was what philfrei and I were talking about in that thread. A change in Java 7 caused AudioSystem to throw that strange mark/reset error when you give it an InputStream from getResourceAsStream(String).

I believe it's pretty stable at this point and I would be happy to see it there, but I don't know if it's really my place to make such a decision. I have one more update that I was planning to push tonight and then I'll just wait for issues to arise (if any).

I really like this library. It doesn't have all the features that Paul's has, but it works great! I use this for all of my projects. The interface is really simple and I am going to recommend this library to anyone that needs a simple library for playing sounds and music!

I really like this library. It doesn't have all the features that Paul's has, but it works great! I use this for all of my projects. The interface is really simple and I am going to recommend this library to anyone that needs a simple library for playing sounds and music!

kuusisto, i'm here to give my feedback about the library. Well, i was looking for a simple library, and when i say "simple", means simple functions, easy and at the same time powerful for my purpose. I tried the "Easy OGG" library, it's a very good library, but in my case i was looking specifically for sound effects, and with the easy ogg library i had no success, cause in sound effects for games we often need to play fast sequences (like a shooter game for example), and the easy ogg isn't good for this (correct me if i'm saying something wrong).

Well, in this case, your library covered everything i needed. At the moment it's working good, no problems or bugs. For sound effects using the .ogg format, is the best that i found. Thank you very much.

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