Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is it possible to downsample mp3 files in Java?

Posted on 2006-07-17
6
Medium Priority
?
421 Views
Last Modified: 2008-02-01
I need the ability to downsample an mp3 file in a utility I am writing.  I currently use the tritonus libraries when doing this for .wav files and this works fine.  However when I try to do the same with mp3's I run into many problems.  Is/are there java libraries that have the ability to downsample an mp3 file?  links would be appreciative.

Thanks
0
Comment
Question by:csciguy81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 17126391
Not sure if JLayer is able to downsample, but have a look : http://www.javazoom.net/javalayer/documents.html
0
 
LVL 2

Accepted Solution

by:
azoapes earned 1000 total points
ID: 17128762
Yes, it is possible. Use the lame encoder: http://lame.sourceforge.net/
0
 

Author Comment

by:csciguy81
ID: 17146610
So would it be better to take an mp3, encode it to a wav, then decode back to an mp3 with a lower sample rate?  Can lame take in an mp3 file and spit back out an mp3 file that has been downsampled?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:azoapes
ID: 17146904
I think you don't have to convert between WAV at all, just check out the command line for LAME: http://lame.sourceforge.net/using.html

It says also that LAME supports free format encoding and decoding. I can get you exactly the command line for downsampling using LAME if you want, but it is easy if you check the link above!

Good luck.

/Simeon
0
 

Author Comment

by:csciguy81
ID: 17147059
woo. it seems like lame works perfectly.  Now. when I am implementing this in java, is there anything I need to look out for?  Would something like this work?

try {
        String command = commandLine = "lame -b 64 "+file1input+" "+file1output;
        Process child = Runtime.getRuntime().exec(command);    
        child = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    }

Would I need to perform a wait on this process or a destroy?  This method may be called by many users at one time.
0
 
LVL 2

Expert Comment

by:azoapes
ID: 17147111
That should work just fine. Sinci you're catching IOException there should be nothing to worry about. If there are many users, you might want to consider making the execution-code (like the one you posted just above here) in a separate thread, but try it as it is firstly.

/Simeon
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

636 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