Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3] 4 5 6
  ignore  |  Print  
  Need a really simple library for playing sounds and music? Try TinySound.  (Read 60790 times)
0 Members and 1 Guest are viewing this topic.
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #60 - Posted 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.
Offline cubemaster21
« Reply #61 - Posted 2012-07-29 18:58:01 »

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?

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #62 - Posted 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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cubemaster21
« Reply #63 - Posted 2012-07-29 20:12:32 »

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?

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #64 - Posted 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.
Offline StumpyStrust
« Reply #65 - Posted 2012-08-02 07:49:25 »

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).

Offline kuusisto

Senior Devvie


Medals: 14



« Reply #66 - Posted 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.
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 842
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #67 - Posted 2012-08-02 12:17:24 »

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.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #68 - Posted 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.
Offline Ziden

Senior Newbie





« Reply #69 - Posted 2012-08-02 20:45:00 »

Hello. Im tryng to use tinysound,im using a compiled version from your repository. Seems to work really fine till now, thanks for the effort.

 How can i use it to load OGG ?

 Thanks for your attention !
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #70 - Posted 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.
Offline StumpyStrust
« Reply #71 - Posted 2012-08-02 23:34:50 »

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.

Offline kuusisto

Senior Devvie


Medals: 14



« Reply #72 - Posted 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.
Offline Rorkien
« Reply #73 - Posted 2012-08-05 18:35:03 »

This works nicely!

But i'm noticing little random cracks in the background while the ogg plays, which doesn't happen when i'm using the LWJGL backend.

 Sad

EDIT: It is really random. But it only seems to happen on 128kbps ogg files. I re-encoded the original mp3 file to 112kbps and 160kbps. No cracks on both!

YAY!
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #74 - Posted 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.
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #75 - Posted 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.
Offline StumpyStrust
« Reply #76 - Posted 2012-08-13 08:46:33 »

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.

Offline kuusisto

Senior Devvie


Medals: 14



« Reply #77 - Posted 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.
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #78 - Posted 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.
Offline StumpyStrust
« Reply #79 - Posted 2012-08-13 16:58:22 »


Quote
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.

Sweet! Grin  Did you at that to a revision I could test?

I thought it might be a garbage collector thing but sometimes you just never know.

Edit:
Tested it and yes loads fast now. With lots of sound files (which I intend) it could get lengthy but nothing a loading screen could not fix.
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.

Offline kuusisto

Senior Devvie


Medals: 14



« Reply #80 - Posted 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?
Offline StumpyStrust
« Reply #81 - Posted 2012-08-14 02:13:46 »

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

What should it be around with 3 sound files all around a minute long?

Offline kuusisto

Senior Devvie


Medals: 14



« Reply #82 - Posted 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).
Offline StumpyStrust
« Reply #83 - Posted 2012-08-14 06:19:54 »

hmmm...I guess meh program is why more efficient then I thought. 10m-60m That is if that snippet gives it back in megabytes.  Wink

I have a lot of GC going around I think because I am not using object pooling with my particle system. I don't know if that would give a speed boost if I did but it would really cut down on GC.

So to bench mark you library a little I have to I can switch between pauls library and yours as my back-end when it comes to managing sound. Right now his loads faster (and of course can to all that 3d mumbo jumbo) almost instant but the quality memory usage are almost the exact same. Your library right now I think is the best option for getting sound into a game or app with next to no hassle. I ran into a munch of walls getting pauls to work mainly because he does not really explain how to set everything up outside of the code.

Edit:
Time for tiny sound to load/stream 3 sound files that add up to 1675kb using .ogg compression. 3600-3700ms (due to tiny having to copy files into temp folder)
Time for paulscode to load/stream same files. 0ms. (Due to pauls streaming files from current location...i think)

Tiny needs a larger heap then pauls but after words memory usage is about the same.

Time to setup tiny with no experience 5-10 minutes including dl time.
Time to setup pauls with no experience 30-75 minutes including dl time.

With experience they would be about the same. Pauls requires I little more management in code but gives more features.

Right now I like both a lot but due to the smallness of tiny I am leaning that way more until I need to make something that requires the robustness of pauls. tiny sound with everything is like 200-300kbs pauls goes into the megs because it requires natives and if you are using his you should be using LWJGL or JOGL (idk if that is the right name).

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.

Offline Sammidysam
« Reply #84 - Posted 2012-08-14 15:48:20 »

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!
Offline StumpyStrust
« Reply #85 - Posted 2012-08-18 11:07:10 »

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-with-sound/26972/msg/239429/view.html#msg239429

I am rather impressed. Loading could be a little faster but it works with almost no effort.

Offline miga

Junior Devvie


Medals: 2
Projects: 1



« Reply #86 - Posted 2012-08-21 00:05:45 »

Awesome work! I used your library on my game. It was very easy to understand and use. Exactly what I was looking for.

Miga's Hobby Programming - http://www.migapro.com
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #87 - Posted 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.
Offline kuusisto

Senior Devvie


Medals: 14



« Reply #88 - Posted 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?
Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #89 - Posted 2012-08-21 03:31:23 »

Any chance we'll see panning functionality in the future of TinySound?

- Jonas
Pages: 1 2 [3] 4 5 6
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (137 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!