ra4king
|
 |
«
Reply #30 - Posted
2012-03-18 17:35:33 » |
|
Yeah that jar I linked is Javazoom's VorbisSPI 
|
|
|
|
kuusisto
|
 |
«
Reply #31 - Posted
2012-03-18 19:47:39 » |
|
Yeah that jar I linked is Javazoom's VorbisSPI  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.
|
|
|
|
ra4king
|
 |
«
Reply #32 - Posted
2012-03-18 19:50:28 » |
|
Corrupted? The download works fine for me :S Try this link?Anyway, my jar is just those three combined together to make distribution easier 
|
|
|
|
Games published by our own members! Check 'em out!
|
|
kuusisto
|
 |
«
Reply #33 - Posted
2012-03-18 22:40:41 » |
|
For those following along, you can now load Ogg Vorbis with the help of three pure-Java libraries included with TinySound. Corrupted? The download works fine for me :S Try this link?Anyway, my jar is just those three combined together to make distribution easier  That link worked, thanks. I still ended up keeping the libraries separate to make it clear what is being included and to allow for different version combinations.
|
|
|
|
|
cubemaster21
|
 |
«
Reply #35 - Posted
2012-04-07 22:54:13 » |
|
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.
|
|
|
|
kuusisto
|
 |
«
Reply #36 - Posted
2012-04-07 23:29:20 » |
|
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.
|
|
|
|
cubemaster21
|
 |
«
Reply #37 - Posted
2012-04-07 23:47:13 » |
|
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.
|
|
|
|
ra4king
|
 |
«
Reply #38 - Posted
2012-04-07 23:50:39 » |
|
Maybe it's because the file is not found?
|
|
|
|
kuusisto
|
 |
«
Reply #39 - Posted
2012-04-08 04:36:36 » |
|
Maybe it's because the file is not found?
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.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ra4king
|
 |
«
Reply #40 - Posted
2012-04-08 04:58:45 » |
|
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.
|
|
|
|
philfrei
|
 |
«
Reply #41 - Posted
2012-04-08 07:04:31 » |
|
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. For example, where fileName is a String: 1 2
| URL url = YourClass.class.getResource(fileName); AudioInputStream ais = AudioSystem.getAudioInputStream(url); |
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.
|
|
|
|
cubemaster21
|
 |
«
Reply #42 - Posted
2012-04-08 12:47:46 » |
|
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.
|
|
|
|
kuusisto
|
 |
«
Reply #43 - Posted
2012-04-08 14:42:22 » |
|
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: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public static Music loadMusic(String name) { if (!TinySound.inited) { System.err.println("TinySound not initialized!"); return null; } if (name == null) { return null; } if (!name.startsWith("/")) { name = "/" + name; } InputStream stream = TinySound.class.getResourceAsStream(name); if (stream == null) { System.err.println("Unable to find resource " + name + "!"); return null; } return TinySound.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.
|
|
|
|
cubemaster21
|
 |
«
Reply #44 - Posted
2012-04-08 15:43:34 » |
|
It goes in the same place as where i put external images, right?
|
|
|
|
kuusisto
|
 |
«
Reply #45 - Posted
2012-04-08 16:31:12 » |
|
It goes in the same place as where i put external images, right?
It really depends. That image directory may not be on your classpath. Perhaps you should try using the loadSound() function that takes a File first. It would look something like this: 1
| Sound sound = TinySound.loadSound(new File("path/to/my/file/sound.wav")); |
|
|
|
|
cubemaster21
|
 |
«
Reply #46 - Posted
2012-04-08 16:38:21 » |
|
I've just tried this, and now it's giving me the error : Error getting resource stream! mark/reset not supported
|
|
|
|
kuusisto
|
 |
«
Reply #47 - Posted
2012-04-08 16:42:51 » |
|
I've just tried this, and now it's giving me the error : Error getting resource stream! mark/reset not supported
Well, the just shows that philfrei was right. Interesting. I'll have to look into this. Can I ask what OS you're running and what version of Java you're using?
|
|
|
|
kuusisto
|
 |
«
Reply #48 - Posted
2012-04-08 17:19:25 » |
|
I just now found what philfrei was talking about in the documentation. From http://docs.oracle.com/javase/7/docs/api/javax/sound/sampled/AudioSystem.html#getAudioInputStream%28java.io.InputStream%29: 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.
|
|
|
|
cubemaster21
|
 |
«
Reply #49 - Posted
2012-04-08 17:36:27 » |
|
I'm running 64 bit Windows 7 with Java 7.
|
|
|
|
kuusisto
|
 |
«
Reply #50 - Posted
2012-04-08 18:13:04 » |
|
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.
|
|
|
|
cubemaster21
|
 |
«
Reply #51 - Posted
2012-04-08 19:14:13 » |
|
huzzah!! it works! Thank you very much!
|
|
|
|
ra4king
|
 |
«
Reply #52 - Posted
2012-04-08 19:50:43 » |
|
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).
|
|
|
|
|
ReBirth
|
 |
«
Reply #54 - Posted
2012-05-13 23:28:25 » |
|
I'm not waitting for that, I already use it 
|
|
|
|
kuusisto
|
 |
«
Reply #55 - Posted
2012-05-14 16:50:59 » |
|
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).
|
|
|
|
kuusisto
|
 |
«
Reply #56 - Posted
2012-05-27 15:54:18 » |
|
Who makes the decision to put things on the list?
|
|
|
|
Longarmx
|
 |
«
Reply #57 - Posted
2012-05-27 16:55:02 » |
|
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
|
 |
«
Reply #58 - Posted
2012-05-27 18:24:29 » |
|
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! Thanks for the kind words. I'm glad you like it.
|
|
|
|
The Cure
Senior Newbie 
|
 |
«
Reply #59 - Posted
2012-07-20 11:51:26 » |
|
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.
|
"A candle loses nothing by lighting another candle" - Erin Majors
|
|
|
|