audio processing using java - java

We have a requirement where we need to convert from .wav file to .mp3 and we are currently using "Tritonus" library to do that . The concern with that library is that requires "installation" of some "dll" files to the class path.
I am wondering are there any API's those allow better processing without local installation.
And other question is ,having mp3 format files will make it easier to join the files into a single file than having .wav files ?

As a former contributor to the JLayer MP3 Library, I'm fairly sure that it doesn't do WAV to MP3 - just MP3 playback and conversion to WAV. (I spent some time optimizing the decoder :-)
Regarding appending files (and possibly other operations), it is generally better to perform edit operations using the uncompressed format, and compress at the end.
I think the spec allows mp3 files to be concatenated, since they are a series of frames, but behaviour may vary from player to player.
So, to be safe, and maintain quality, I'd concat using WAVs and then compress the final result to MP3. Concating files is not so straightforward - you have to at least make sure they are at the same percieved volume, or you will get a noticible shift in volume from one file to the next. Such operations are definitely best performed on the uncompressed data.

The JLayer MP3 Library appears to support several operations on MP3 and WAV files including conversion, with no native libraries to install.

You can use MP3SPI to do this. This is a java sound plugin, just include the jar into the classpath, and you can use java sound api to convert between wav and mp3.

Related

Convert mp3 to WAVE in java without external libraries

Is there a way to convert a mp3 audio file into a wav audio file in java without using external libraries?
If you want to tell java "hey, convert an mp3 file", it won't do that, because it isn't made for mp3.
If, however, you are comfortable with using a purely java library, then check out JLayer. I have used it myself and it worked wonderfully.

Play m4a files in Java

I want to create a media player in Java. The mp3 support already works with the JLayer library but which library can play m4a files?
I read about vlcj here on stackoverflow, but this seems to depend on Swing/AWT which I wouldn't use because I want to port the application to Android later on.
Have you looked at JAAD? It's a Javasound SPI that decodes AAC audio, I've used it with success previously.
Note that m4a is a container format, and while it usually contains (in my experience) AAC audio, in theory it could contain other formats instead.
You can find some information about getting it working without Javasound (and a test case) here.
This answer is indirect. I don't really know anything about m4a files. But what I have found is an open source library that can stream them as a flash server named red5. It's written in Java so theoretically you should be able to browse their code to figure out how to do it.
Hopefully someone here can give a more direct answer, this is the best I can do.
If you have Java 7 or later, you have access to the Javafx library. You can also use your media player (like iTunes or Windows Media Player) to convert to the simpler mp3 version and run that. I wouldn't recommend .wav files as they have significantly more data usage than mp3s, (which condense the file size by compressing the .wav data and omitting inaudible and otherwise garbage-y data).
import javafx.scene.media.*;
String name = "song.mp3";
Media song = new Media(name);
MediaPlayer player = new MediaPlayer(song);
player.play();

Using JLayer (AKA JavaLayer) to analyze mp3 files in java?

I would like to perform a FFT on frames of an MP3 file using Java (think spectrum analyzer). I found JLayer which seems to fit the requirement of MP3 Decoding, but I'm not sure how to use it (Most examples are simply players that use the higher level helper, but that's not what I am looking for). FFT seems easy compared to decoding MP3 files ;)
My question is basically this: How would I take an MP3 file in java, and decode it to raw audio data for analysis in Java using JLayer
I am on the same Boat - trying to decode and analyze MP3 files using Java. You may want to check out MP3 SPI from the same author. There is a good example of getting the raw decoded PCM data from an MP3 file in his page:
http://www.javazoom.net/mp3spi/documents.html
Good luck,
Uri

Video converting into mp3 on Java, Android

I need to convert mp4/flv files info mp3 in my Android application, but I don't know C/C++ and Android NDK. Do you know libraries/methods for easy converting on Java? Thank you for anyway.
Your question is how to extract audio from MP4/ FLV files and save as mp3 file. Right ?
Then, very sorry, Android SDK does not provide any API for transformating or track extraction.
Also using available media framework to achieve the same is also not trivial (and even if you do, you will lose portability).
What I would suggest is to use your MP4 & FLV Parser to extract audio track, do transcoding (if audio track is non-mp3), and save the transcoded (if audio track extracted is mp3, then extracted data) data.
Or you can port FFMPEG code base and use the same. This again may be overkill for your small task.
Suppose you just want to extract mp3 track from MP4, then you understand the native mp4 parser and use the APIs for extraction. You may have to replicate some code from stagefright / opencore.
Shash
it's probably irrelevant for you anymore but if some one still need a mp4 to mp3 parser here's an api that can do the job

Playing small sounds in Java game

For the computer game I'm making, I obviously want to play sound. So far, I've been using AudioClip to play WAV files. While this approach works fine, the WAV files tend to be gigantic. A few seconds of sound end up being hundreds of kB. I'm faced with having a game download that's 95% audio!
The obvious option here would be to use MP3 or Ogg Vorbis. But I've had limited success with this - I can play MP3 using JLayer (but it plays in the same thread). As for Ogg, I've had no luck at all. Worse, JLayer's legal status is a bit on the dubious side.
So my question is to both Java developers and generally people who actually know something about sound: What do I do? Can I somehow "trim the fat" off my WAVs? Is there some way of playing Ogg in Java? Is there some other sound format I should use instead?
You could use JOrbis library to play back OGG music. For working sample usage you can look at these files here.
I also experimented with some lossless audio compression, for example I had a 16 bit mono sound. I separated the upper and lower bytes of each sample and put them after each other. Then I applied a differential replacement where each byte is replaced by its difference from the last byte. And finally used GZIP to compress the data. I was able to reduce the data size to 50-60% of the original size. Unfortunately this was not enough so I turned to the OGG format.
One thing I noticed with 8 bit music is that if I change the audio volume, the playback becomes very noisy. I solved this problem by upsampling the audio data to 16 bit right before the SourceDataLine.write().
These may be outdated, but they are officially recognized by the Xiph.org team (who maintain Ogg and Vorbis, among others).
http://www.vorbis.com/software/#java
The problem you describe is addressed by the Service Provider Interface (SPI) for sound in Java. The result is that simply adding JAR files to your classpath will add functionality to the default Java Sound API. Thus enabling the handling of more sound formats without changing code.
Last time I tried this the Javazoom people offered a working MP3 SPI JAR. Which was based on the JLayer you mentioned.
For Vorbis OGG there now also seems to be an SPI library. Check out the docs on the Vorbis SPI on Javazoom.
If you decide to stay with wav format...
It is probably not very important to have high quality sound files. You can use your favorite wav editor to lower the bit rate, switch to mono, or both. That will save tons of space and you won't notice the difference in quality while playing the game.
Hope this helps.

Categories

Resources