I have a situation, i have data and source sound format. For example, if i wand to process .MP3 file then format of the data like bitRate, sample rate, channels etc. have in the one object (You can consider that object as like simple object containing getter/setter for all properties). And, all related data in another object/file (Like in byte array). I have both format and data separate not in same file like normal .MP3 file.

Know i want to convert that data in to PCM format so that i can play using the javax.sound..... package classes....

If any one have idea then its most welcome.Any help would be appreciated.....

JLayer is an MP3 decoder in java so maybe you can use that.I'm not completely understanding why or how you have your data separated from the format data, but if your separated files are still based on mp3 you might have to adapt JLayer to your needs (it's open source). Or roll your own...

I have one application that originally written in to the C++, that application access the video data from our hand written server. That server work like RTP server. In abstract, server first sends the audio data format (It may be in any format like PCM OR compressed using any of the technique), then sends the audio data in given format. The client application convert that audio data in to PCM if it is not in that format and plays it.

Know we are converting the client application in to the Java, server application is same, not changed. Hence, we have to achieve same functionality in Java.

By default windows has in built API/Functions to convert a different sound format in to PCM format.

You might want to read about Java Sound SPI. Per default, JavaSound doesn't support many formats, so you need extensions in the form of an 'SPI' (Service Provider Interface) to get support for additional formats like MP3.

WAVEFORMATEX is a Windows specific struct which describes an audio stream.wFormatTag is an enumeration of the audio format, which can be things like PCM, MP3, whatever. The value 85 probably means MP3 in your case.cbSize is the size of exData, which stores more properties about wFormatTag.

The problem is that this is Windows specific data, so there's no standard API in java to handle it.If I were you, I'd first assume MP3 and just try to use JLayer to play the stream associated with this WAVEFORMATEX struct. Not sure if that's going to work immediately, you might need to use some of the struct's data for example to be able to parse the stream, but I also wouldn't be at all surprised if it does Just Work in the case of MP3...

I have another problem, how i can mix sound balance and volume?. In Java, there are some controls like float control using that i can change volume and balance of the SourceDataLine (javax.sound.sampled). But here i have different situation. I have more than one SourceDataLine opened and all are playing individual audio file (Streams). I have to changed volume and balance (Sterio sound) of only one stream. I mean balancing effect should come on only one stream, other stream should not get effect of balance and volume.

If i use Java float control then it would affect all playing streams/file.

My understanding is that you query a Line for available Controls, but a Mixer is also a Line. So I'd guess that if you get a Control from a Mixer, you'll get a global Control for all it's lines whereas if you'd get a Control from an individual Line, it should work independently.

I'd have to check to be sure (haven't tried it in a long time), but IIRC this is how it works.

I now able to play the MP3 stream. Here the process what i have done to play that.

I have downloaded the MP3 SPI suggested by you and registered it. Now, i am generating one WAV file using audio format and audio data sent by the server. I am creating a file that is in same format as windows WAV file format (http://ccrma.stanford.edu/courses/422/projects/WaveFormat/). We can play that generated file using the javax.sound classes.

Another process, if you have a audio data in the file and MP3 SPI registered, you can directly get AudioInputStream using AudioSystem.getAudioInputStream(InputStream stream) method. It automatically analyse the data and determine the format of that data.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org