Hi,
I’m making a rhythm game using jME at this time only the sound part is in work and I have a few questions about the sound system in jME.
I didn’t found it (but maybe I’ve not well searched) and I want to know how to load a MP3 file. I really need to use this format because I’m not the creator of the songs and a lot of songs already exists and uses mp3. I’ve seen that JMF can decode a lot of format including mp3, but I don’t really like the fact that JMF is not redistributable.
So is there any work made to load mp3 in JME or must I use another library ? (or recode a mp3 decoder ? :p)
Another question is concerning sound buffering. The game have a background track which is compound of a lot of separate wav samples. Currently I play this track with a loop and play each sample when needed (with the play() method of AudioTrack class), but I think that generate this background track can be a good think. For example, if there is a software lag the samples will not be played offbeat and because I will use a lot of sounds it will not reach the 64 track max of OpenAL at the same time easily.
Do you think is it a good idea ? Do you have any idea to implements it ? May I use another audio library (like FmodEx) ?
Thanks for your help (and making such a good game engine :D)
Mr_Qqn
PS: For those who are interested by what is my project (and speak french :p) I’ve a development blog at : http://mr.qqn.free.fr/.
I'm not sure if you can load mp3 in jME's sound system somehow, but due to the licensing problems with mp3 I doubt it.
Why don't you just convert all your sound files to ogg instead?
The idea of prerendering the background track is not only good, I'd consider it absolutely mandatory for the game to work at all.
Timing fluctuations within the range of several tens of milliseconds are perfectly normal in consumer sound cards, but can entirely ruin the "feel" of a rhythm, or even completely destroy it.
So the only way to achieve a reliable timing on those cards is to either prerender the audio or use software mixing, which is not an option for real time music applications due to long latencies.
You can render the audio using the Java Sound API, but be warned, Java Sound has a steep learning curve if you don't have previous experience with low level audio coding!
I do believe currently only wav and ogg are supported by jme.
aaarrgg… java sound… I was sure that I must use a low-level API to make sound buffering. But since I must use a low-level API, I wonder what API choose between OpenAL and Java Sound. I think that OpenAL is more powerfull but maybe more complex… Later I want to add sounds effects like reverberation, low pass, etc… and I think that OpenAL includes some but in java sound I think I'll have to recode the effect algorithm.
What do you think is the better choice (for someone who really don't like low-level programming :p) ?
Yes jME only include decoder for wav and ogg and not for mp3 that's why I'm looking for a class like Mp3InputStream that will do the work. I've heard too that mp3 have some licensing problems but I don't know what they are really.
I could convert mp3 to ogg, but the problem is that a song is compound with a lot of samples and a text file (BME) which contains all informations to play what sample at what moment. This is a format that already exists. So if I convert mp3 to ogg the song will not be compatible with other BME players which don't decode ogg and by the way it may take a lot of time to convert before the first play. (I don't know if it's enough clear :s).
Even if I think ogg is a better format than mp3, there are currently a lot of song using mp3 that's make I must decode mp3 in the game.
(Sorry for my english, I'm not sure of the accurate of some sentences)
I don't know if rendering audio to a file (non-realtime) is even possible with OpenAL. The effects stuff may well be easier/more performant to do with OpenAL, but as I said above, I don't think you can get a reliable timing with hardware accellerated sound mixing on consumer hardware.
Then again, don't let my preconceptions get in your way! The last time I have dealt with audio related programming was a couple of years ago, so things may have changed in the meantime (not likely, though).
I'm afraid that if you really don't want/like to do relatively low level audio coding as in Java Sound, you'll have to go looking for a framework to help you. I don't know of any such framework for java, but of course that doesn't mean it don't exist.
About the mp3 licensing problems, I am not sure about the specifics either.
Try searching online, I know a lot of people needed MP3 playback in Java. You might find something that works for you.
You can also find the old mp3 support in jme's java.net cvs repository. It would have to be modified to work with jmex.audio though.
Thanks, i'll try to use to old work for mp3 of jme 1. Concerning the licensing, it's quite expensive but free for games that are distributed under 5000 times (http://mp3licensing.com/royalty/games.html).
And for buffering before using java sound or OpenAL I'll see if I can do this by extending AudioInputStream. If I've weel understand how the audio part of jme is made I think it will work.
I just finished to adapt the old class for mp3 decoding and it work perfectly. If someone is interested by having it just ask me.
ummmm, just I think…[glow=red,1,100] EVERYONE [/glow]!!!
BBBUUUUTTT, the licensing issue is a concern (and why was it originally taken out I wonder…); maybe you could just post it under momoko_fans snippet page http://jmonkeyengine.com/wiki/doku.php?id=code_snippets_-_jme_2 … (Perhaps with a nice disclaimer and your link about 5000 releases).