Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2013-03-14 16:16:44
TinySound should work fine on Linux because it mixes all audio to a single line.  This was actually one of the problems that I was trying to address when I created TinySound.  I did once observe a latency issue with some drivers that I had installed, but others might be able to comment on their experiences.
2  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2013-03-03 20:34:03
Well, using mbInUse actually made me see the difference of 160 to 240 but I believe that it's still stupidly high

That is high.  Can you post all of the code you're testing with?

Edit:
I just took your code that you most recently posted and added the minimum amount required to get it running.  I see what you mean about the memory usage, but it appears to be a result of the fact that you load and unload the Sound on each iteration.  When I added a
1  
System.gc();
right before the sleep, I was seeing less than 1MB of memory usage at the end of each iteration.  The moral of the story is that you shouldn't load and unload so much.  If you're going to use some music, load it and store it somewhere until you're done with it.  If you're using the streaming implementation, the Music object itself should take up very little memory, so there's no reason not to hang onto the reference.

Please let me know if that helps.
3  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2013-03-03 20:04:39
Again, sorry I haven't been on in a while.  I've been crazy busy with my academic life.

What TinySound does when streaming is it first loads the whole thing into memory to convert to the correct format, writes it to a temporary file, and then streams that.  It can thus end up using a lot of memory at loading time, but that should be drastically reduced when streaming.  Now, depending on how you monitor memory usage, it can still appear to be using a lot more memory.  If you just look at how much memory the JVM has been allocated (e.g. the Task Manager on Windows, or top on Linux), it will be large.  This is because it needed that memory at some point.  The actual heap space in use when streaming, however, should be much lower.  You can tell how much memory is actually in use with something like:

1  
double mbInUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576.0);

A better solution would be to convert the audio data to the correct format as it's being read and written out to the temporary file, but I haven't done that.  I don't think it's trivial either.
4  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2013-01-26 23:57:19
About the delay, 50 ms were also fine for removing the crackling. I didn't noticed any lag (core i5 laptop and core i7 desktop, both java 1.7). Maybe just happens with slower computers or other JVM. Why does it happens? because the computer takes a lot of time filling the whole buffer for the first time? Interesting. I will take a look again at the code.
You're right, it could just happen in slower computers, but it would generally happen if there were ever a fairly large gap between buffering updates.  It's all mixed and sent to one SourceDataLine, so if you buffer 100ms on the line, the next audio played won't actually hit the speakers until that buffer is complete.  I can't recall now if I have designed it so that it recovers from long buffers, which would make a 100ms buffer less of an issue.

BTW, as I saw in your page, you are doing your PhD, right? good luck!! I wish you to publish a lot of papers Tongue
Thanks!  I am working on a PhD, and I guess only time will tell if I can really stick with it.  The whole process can be quite a long haul.
5  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2013-01-26 21:51:35
Sorry I haven't been on in so long.  I'm rapidly approaching a few deadlines in my research, so I've been pretty swamped (probably will be for a while actually).

Also, I've been working some more with this library. I found  (in my opinion) an important limitation. As I can understand, by now, a sound cannot be played twice simultaneously. You need to load different sounds with the source file (waste of memory).
You should be able to play a Sound multiple times simultaneously.  When you call play(), it creates a reference to the sound data and passes it off to the mixer.  Can I ask how you came to this conclusion?  If it really isn't working, it's possible there is a bug.

Increasing maxFramesPerUpdate for storing up to 100ms of data per iteration into audioBuffer worked great! No more crackling, the music became smooth and perfect.
So, if there is not any extra problem, maybe is a good idea for futures updates to increase the default buffer size from 25ms to 100 ms or even more.
If I recall, the reason I had it at 25ms was to reduce latency.  If it buffers up too much audio data there can be some audible lag between the time a sound is 'play()'ed and the time that it actually plays.  It might be a good idea to up the default a little bit, but I'm reluctant to increase it to 100ms.  That said, I'm glad it works so well for you though.  I also think it's really cool that you're using TinySound and have taken enough of an interest to dig in the code!
6  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-10-24 03:48:40
On the game I used this library, I credited with your name. If you have a website with this library hosted, I would like to know so I can add a link on my citation.

Thanks.
I've merged in the streams_and_redesign branch and now have a prettier page for TinySound thanks to GitHub Pages.  You can link to this instead if you want.
http://finnkuusisto.github.com/TinySound/
7  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-10-21 16:28:14
You can and should (I think) post you library on this wiki:

http://www.java-gaming.org/topics/java-gaming-resources/26897/view.html
I posted it there a few days ago, but I forgot to thank you for the suggestion.  So, thanks for the suggestion.

On the game I used this library, I credited with your name. If you have a website with this library hosted, I would like to know so I can add a link on my citation.
Cool, thanks.  The license I used doesn't require attribution like this, but I appreciate it.  I don't actually have a web page for TinySound, but you could just link to the repository (https://github.com/finnkuusisto/TinySound) if you want to link it to something.  I should probably think about making a web page.
8  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-09-22 23:03:33
The second you make a panning-system, this will become my main sound-library, and though shall get much praise in my credits Cheesy
Oh, and the ability to enable random pitching within a specific range. I'd love that!
Well, I didn't add random pitching, but I did add panning and it can be found on the streams_and_redesign branch (I'll eventually merge it to the trunk).  Give it a go and see what you think.  I'm not entirely sure how panning is normally implemented, but you can set a pan value in the range [-1.0,1.0].  0.0 plays normally, whereas a negative or positive value shifts a proportional amount of one channel to the opposite.  More specifically, a value of -0.25 will shift 25% of the right channel to the left channel.  Note that panning to the left doesn't change the gain on the original left channel audio at all.  It only affects how much of the right channel is shifted.  The analogous situation goes for panning right. 
9  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-09-12 02:27:47
Yup. I was going to code something like that next but decided not to. Sure you can do everything Tiny does yourself but that would defeat the purpose of a library. I am just saying it would be a nice feature to add.
I apologize for disappearing again for so long.  You make a good point, so I've added a done() method to the Music interface which will tell you when the Music has finished.  I've also fixed Music to stop "playing" when it's finished, as you mentioned the issue with playing() always returning true if you haven't called stop().  Note that you will have to call rewind() to set a Music back to the beginning.  All of these changes are on the streams_and_redesign branch.  Again, sorry for disappearing.  I've had a lot on my plate.
10  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-21 03:46:41
Any chance we'll see panning functionality in the future of TinySound?
I suppose that's a possibility if I can find a good resource for the math involved, or if I can figure it out for myself.
11  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-21 02:49:36
Requested features from Tiny:
Global volume. Right now I just loop through all loaded sounds and set the volume but a global would be nice.
Because the Music lets you loop sounds where the regular Sound does not I only use music because I want to loop not music files at times. Could you add looping to regular sounds? or make only one sound type that does it all? Idk just suggestion.
Sorry I took so long to respond.  I've been busy with research and another project that I've been working on for a friend.  The global volume is such a good idea, I just added it tonight and you can find it on the same branch that I've been working on for streaming sounds.  It doesn't change the volume of all the Sounds and Musics, but instead acts as a global multiplier to the individual volume settings.
I've considered adding the ability to specify a fixed number of times to loop a sound when you call the play method.  The reason I didn't add continuous looping to Sounds in the first place is because I intended for them to be played in potentially overlapping fashion.  In order to control the looping of a particular playing instance, you would need a reference to it for each call to play().  Would the ability to have a particular playing instance loop for a fixed number of times suit your needs?
12  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-21 02:38:36
This is very helpful!  I used this as my first attempt at adding music and sound to anything, and it works very well.  I haven't added sound yet (just music at this time), but I did set up a music player that plays a random song in the list, waits until it's done, then plays a random new one from the list.  Thank you!
If anyone wants to know what you can do with this here is an example game I have made where all sound is done with Tiny.

http://www.java-gaming.org/topics/neobat/26972/msg/239429/view.html#msg239429

I am rather impressed. Loading could be a little faster but it works with almost no effort.
Awesome work! I used your library on my game. It was very easy to understand and use. Exactly what I was looking for.

Wow, thanks guys.  I haven't been on in a while, so I hadn't yet seen these posts.  I really appreciate the comments.

Edit:
StrumpyStrust, that is super cool.  I really like your particle effects.
13  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-14 02:55:45
No I have been just using task manager. Which is not the most accurate. I checked to see if gc was being called and it is. I also think that ogg files seem to use more ram then .wav
Ah, I see.  That will give you a rough idea of how much memory has been allocated to the JVM, but not necessarily how much is actually in use.  If you want to determine how much memory the JVM is using, try this little snippet:

1  
double mbInUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000000.0;


What should it be around with 3 sound files all around a minute long?
Well, after they're loaded into memory and converted, that would be 3 minutes of 16-bit, 44.1 kHz stereo, linear PCM.  That means there are 4 bytes per frame (2 bytes for each channel), and 7,938,000 total frames (44.1 kHz * 180 sec).  That comes to a total of 31,752,000 bytes, or 31.752 MB.  Of course, that's if the data actually stays in memory as is default in TinySound.  With the streaming code, the memory used should be equivalent to however much the streams have buffered in memory at any one time (which is probably something like 8 kB each).
14  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-14 01:17:55
The memory is lower as in I can drop the heap size down to 128m and it sits at 110m-120m but System.gc() does nothing so :/ I don't know how to force a GC and I don't even think you can. I know that it will have to have a heap big enough to load what ever your largest sound file is.
That seems a little odd, though I guess a call to gc() is just supposed to be a suggestion.  How are you computing your memory usage?  Are you subtracting free memory from total memory?
15  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-13 15:10:46
So I have tested your new code and yes the load time is very very...very long but unfortunately it still uses almost the exact same amount of memory. I am not sure if I am doing something wrong but not a huge change. 160m-180m to 160m  Clueless

Keep working on this as I am a nub at sound processing right now and this would be a great library for simple games.
Well, I fixed the load time at least.  I thought FileOutputStream was buffered, but I guess it's not.  Wrapping that with a BufferedOutputStream dropped my test load time from almost two minutes to under ten seconds.
16  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-13 11:53:05
So I have tested your new code and yes the load time is very very...very long but unfortunately it still uses almost the exact same amount of memory. I am not sure if I am doing something wrong but not a huge change. 160m-180m to 160m  Clueless

Keep working on this as I am a nub at sound processing right now and this would be a great library for simple games.
Well, it still loads everything into memory for conversion before writing out to a temporary file, so it's possible the garbage collector hasn't kicked in.  I just saw the same thing with a test of my own, but when I put a call to the garbage collector after my loading code, it reduced memory usage dramatically.
17  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-13 03:06:33
If you got the streaming working you would be my hero and I would bake you a cake  Grin...it may go bad in the mail tho.
I did a bit of redesign and refactoring to add the ability to stream audio data from a file.  I haven't tested it much, but it seems to be working so far.  There's still a bit of work for me to do, but I have the new version on a separate branch.
https://github.com/finnkuusisto/TinySound/tree/streams_and_redesign
Give it a try if you like.  It takes a long time (read: very long time) to write the audio to a temporary file, and I'm not entirely sure why that is yet, but I'll keep working on it whenever I have the time.
18  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-05 20:52:15
I re-encoded the original mp3 file to 112kbps and 160kbps. No cracks on both!
I'm glad that's working.  Still, it is odd that it was cracking.  There are two places that I can think of where the cracks would be introduced: 1) In TinySound's update thread writing to the speakers, or 2) in the conversion code from Ogg-Vorbis to linear PCM.  Given that it was fixed when you changed the encoding, it was probably the latter.  If so, it takes the blame off of TinySound and puts it somewhere in the other jars, but that would also mean there is nothing I can do to help.
19  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-03 01:30:40
If you got the streaming working you would be my hero and I would bake you a cake  Grin...it may go bad in the mail tho.

Just want to say keep up the fantastic work.
Haha.  Well, I'm already working on it.  I can't make any promises, but I should have a good chunk of time to work on it on Sunday.
20  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-02 22:29:46
How can i use it to load OGG ?
In order to load OGG Vorbis files, you'll need to include the other jars located in the lib directory in your classpath.  That is, you need to include tritonus_share.jar, jorbis-0.0.17.jar, and vorbisspi1.0.3.jar in your classpath.  If you're using an IDE like Eclipse, you can just reference them in your project the same way you did with tinysound.jar.
21  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-02 13:27:45
As a quick and dirty workaround, you should uncompress the audio files to the temp-dir, and stream those uncompressed files. This prevents unacceptable memory usage for long audio.
Streaming audio is definitely something I've thought of adding to a future version of TinySound.  I've opened an issue on the repository to remind myself.
22  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-08-02 12:11:23
So I tried this because I am newbs at sound and first thing I get is out of memory errors. I had my VM set to 32m which is lower because I am trying to make sure I do not hog mass amounts of memory. I had to bump it up to 256m and the program now sets at around 132m. Is this normal for sound? Seems like a huge jump just for a few sound files. (3 to be exact).
TinySound doesn't do any intelligent loading/unloading or streaming of audio.  It just loads the entire audio file into memory and keeps it there until you call unload on the Sound/Music or until you shutdown TinySound.  The amount of memory each file takes up is almost exclusively dependent on its length, as TinySound converts all audio to 16-bit, linear PCM audio at 44.1khz sample rate.  You can save memory if your files are mono as opposed to stereo, but even compressed formats (such as ogg-vorbis) are converted when loaded into memory, so you only save disk space with those.
23  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-07-29 20:24:22
I am using an older version, but it works fine on my computer, but not theirs, does it have something to do with audio drivers or something like that?
It can depend on drivers, but it can also depend on the version of the JRE that they are using.  Regardless, I would still recommend using the most recent version as the bug seemed like it would be problematic in a good number of cases.
24  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-07-29 20:01:32
I've been using this in a couple of games of mine, that i've only tested on my computer. I sent it over to my friend for testing and when it came time for sound, he got [this error][/http://i.imgur.com/Tqrq9.png?1]. Any idea what happened?
Hmm, It looks like you may be using an older version of TinySound than is currently in the repository.  It appears to be failing to convert the audio format of the sound files, and I definitely fixed a bug related to that relatively recently that was dependent on the version of Java you have installed.
25  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-07-20 14:40:26
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.

Awesome, thanks.  It's really nice to hear that people are actually using TinySound.
26  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-05-27 18:24:29
I really like this library.  Grin 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.
27  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-05-27 15:54:18
I'm curious if TinySound has "matured" to the point where it could be added to the list of Resources on the "Java Gaming Resources" link.

http://www.java-gaming.org/index.php?action=resources
(link directly under the JGO logo)
Who makes the decision to put things on the list?
28  Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-05-14 16:50:59
I'm curious if TinySound has "matured" to the point where it could be added to the list of Resources on the "Java Gaming Resources" link.

http://www.java-gaming.org/index.php?action=resources
(link directly under the JGO logo)
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).
29  Java Game APIs & Engines / Java Sound & OpenAL / Re: Selecting non-default Mixer on: 2012-05-02 18:54:19
It sounds like the most appropriate solution is to just add a second init() function which takes a Mixer.Info, so the user can specify which Mixer to use.  I'll, of course, leave the current init() function in as well, which uses the AudioSystem.getLine() function.

I'd say yes to the two init functions, but use the first mixer that supports outputs by default. Using a line from AudioSystem.getLine will get you lousy performance in some cases, particularly on Linux. This is because AudioSystem looks for mixer capable of playing multiple lines, so ignores the direct mixers because they can only use a single line. As you're doing software mixing, you want to benefit from the better performing mixer by default.

That's reasonable.  Thanks for all your help and advice.
30  Java Game APIs & Engines / Java Sound & OpenAL / Re: Selecting non-default Mixer on: 2012-05-02 17:40:28
It sounds like the most appropriate solution is to just add a second init() function which takes a Mixer.Info, so the user can specify which Mixer to use.  I'll, of course, leave the current init() function in as well, which uses the AudioSystem.getLine() function.
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!