Any Good Recommendations for Mp3/Sound Libraries for Java

Recommendations for music processing library?

To find frequencies plotted in time with code you will probably have to do some frequency-domain transformations to obtain that, such as FFT or wavelets. What you obtain as raw data in an audio file is a discrete signal of time-varying voltage. Python has a built-in library for wav files, and with numpy you can do the FFT analysis on the signal.
One suggestion I have is PureData (http://puredata.info/) , a visual programming environment for musical purposes. That software will help you a lot, and save you a lot of trouble with the DSP part of music software development. With PureData, you can use frequencies plotted in time easily. If the idea is to develop something for a music theory class, it is a great solution.

Playing .mp3 and .wav in Java?

Java FX has Media and MediaPlayer classes which will play mp3 files.

Example code:

String bip = "bip.mp3";
Media hit = new Media(new File(bip).toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();

You will need the following import statements:

import java.io.File;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;

Best addon for reading data from .mp3 with JDK 1.6

However, the jdk..

It is not the JDK that matters, but the JRE.

..can only load .wav files. ..

It can load (a subset of) the types returned by AudioSystem.getAudioFileTypes(). If you check the docs for AudioFileFormat.Type in Java 7, you'll see a list of 5 types, but the ultimate check is what the JRE returns.

.. So I'm looking for a flexible addon that'll enable me to load .mp3.

The mp3plugin.jar of the JMF can be added to the run-time class-path to add support for MP3 decoding to JavaSound.

Lemme know if you've attempted music visualizers before.

Music Visualizer

Yup ;)



I made this wonderful starry background and thought the stars should twinkle and glow based on the music. Do you think it's possible to detect the odd instrument that's playing? Like drums or strings?

I recently broke my own player and am busy with other things, as such I'm using WinAmp to play my favorite tracks and watching some of the (300+) visualizations WinAmp offers. The reason I mention that is that my traces are of two types, 'oscilloscope' style & a 'Lissajous' style. Check the YouYube site linked above for examples of each.

WinAmp OTOH offers a plethora of seemingly quite different styles, some of which are closely tied to the music visually, and others which are entirely unrelated (just pretty animations in their own right). I figure the ones that have a linkage to the music (beyond representing the trace itself - like my software), are basing their graphics on the volume of the signal, which can then sometimes represent a beat.

The correct way to calculate the volume is to come up with a number in decibels (dB), but in my software I implemented a simpler algorithm to detect the RMS of each channel. You can see those volume bars in a Rasputina Track.

Visualization with RMS levels

They are not especially clear in (the lower left/right of) that image, but watch the video & I think you'll find they are easier to see & offer a good basis for the 'pulsating stars' type of effect you are after (a number to multiply a basic brightness by). To get stars to twinkle differently according to frequency (e.g. bass - low, violins - high) you'd need to look to something like spectrum analysis - a Fast Fourier Transform is one way to do that.

Is there a Google Sound API

No, there is no Google Sound API, unfortunately.

Playing small sounds in Java game

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

Problem recording audio on Android and playing on Swing (PC)

On this thread you can find numerous java API to playback audio files :
Any good recommendations for MP3/Sound libraries for java?

Also, you probably want to write a desktop application, not an applet. Applets are an old technology that never really catched up (to be honest Microsoft helped quite a lot to kill that tech...).



Related Topics



Leave a reply



Submit