?
Solved

Is there a way to compress a .wav file so that it works in Java?

Posted on 2004-11-13
12
Medium Priority
?
465 Views
Last Modified: 2011-09-20
I have a 400k .wav sound file that I want to compress to use in my Java application.  

I tried MP3 but borland JBuilder doesn't recognise mp3s as sound files (as far as I can tell).  

Can anyone suggest a way to compress a .wav file so that it will work in Java?  Here is how I am using it:

private static AudioClip SIMULATION_END = Applet.newAudioClip(Sounds.class.getResource(DIR+"scifi.mp3"));
0
Comment
Question by:Dawkins
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 total points
ID: 12576181
0
 
LVL 92

Expert Comment

by:objects
ID: 12576192
you could try zipping it.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 12576198
If you include the audio in your jar then it will get compressed along with the rest of the jar so you don't need to worry about it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 200 total points
ID: 12577405
Forget about zipping: .wav is like white noise: uncompressible.
The only solution is .mp3
Btw.: mp3 is not a compression but a kind of reduction (you will even loose some quality).
<*>
0
 

Author Comment

by:Dawkins
ID: 12578066
Yes I've noticed it doesn't compress very much using winzip or into the jar.  Mp3 got it from 400k to 80k.

So, Java doesn't recognise mp3 without using 3rd party classes?  In that case I think the best option is to find a different sound to use because I want this done by tomorrow!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12578091
You can download the MP3 library in 5 minutes (I did it on 33KBAUD).
Just follow http://www.javazoom.net/javalayer/javalayer.html
like I did.
<*>
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12578099
Btw., CEHJ : congratulations with the 2 000 000 !
<*>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12578215

>>Java doesn't recognise mp3 without using 3rd party classes?  

No

>>Btw., CEHJ : congratulations with the 2 000 000 !

Thanks
0
 

Author Comment

by:Dawkins
ID: 12578405
ok I've found a smaller wav to use instead so problem solved.

>If you include the audio in your jar then it will get compressed along with the rest of the jar

There is an option to compress but it is not ticked by default.  I tried it and it decreases the .jar size by 50% so thanks for mentioning it! :)  

But are there any drawbacks to compressing the jar (other than taking slightly more time to compile and build)?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12578413
>>But are there any drawbacks to compressing the jar

Well, the overhead of uncompressing it of course ...;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 12579484
> But are there any drawbacks to compressing the jar (other than taking slightly more time to compile and build)?

no
0
 
LVL 2

Assisted Solution

by:javazoom
javazoom earned 200 total points
ID: 12582053
If you plan to use JLayer from :
http://www.javazoom.net/javalayer/javalayer.html

Then MP3SPI should fit better to your need because you don't have to modify your JavaSound code to play MP3 and WAV. It's a MP3 plugin. It relies on JLayer :
http://www.javazoom.net/mp3spi/mp3spi.html

I hope it helps.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question