Solved

Is it possible to downsample mp3 files in Java?

Posted on 2006-07-17
6
404 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 250 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
Industry Leaders: 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!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

739 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