Skip to main content
gamedev.net
🔒 Locked

[java] music for game

Started by role 15 replies 2.2k views
Original Post
role
role
what kind of music do u all use for your games? i tried to use .wav but i got java.lang.out of memory then i convert it to .au but still got the error i cut it half, and it works!! but it takes memory up to 30 megs! woah, i would rather play the games without music! okay thanxx
NuffSaid
NuffSaid
MP3s or MIDI are good choices for Music. Check out the Java Media Framework for more libraries to play such files (esp Mp3, standard VMs should be able to play MIDI).

A full MIDI song normally is less than 50KB. But the only drawback is you''ll need a good soundcard, otherwise you''ll hear cartoonish music.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
SI_78
SI_78
I''m probably missing something here, but can''t you double buffer your audio, you load in one buffer (about 50k per buffer) and play from the other. Then when you''ve finished playing you swap buffers and play from the one you''ve just loaded and load in to the one you were previously playing? Not sure how easy this is to do in Java, I''d imagine there''s an object that handles thsi sort of thing?

Need coffee brain not working fully.....
_nomad_
_nomad_
i''m not really into java, but does java not have any capability to stream audio files? just asking...
_nomad_
_nomad_
i''m not really into java, but does java not have any capability to stream audio files? just asking...

nomad | nomad forum
Wrathnut
Wrathnut
I use the .au files for my in game music. Personally I tihnk you are right the media, for a dial up connection, gets outrageously large especially for background music. What I usually to is make a sample that is small enough to be downloaded properly and loops well... Then just loop your BGM. This does tend to make the BGM repetive and if you do it like this you SHOULD give the player the option to tunr the music off.

Conversely depending on the type of game you have this could be a good thing too. If you have several samples that loop well and aren''t too annoying you could make them play in a sequence or even set them up to play when something happens in game,this could help set the atmosphere of the game.

Good luck!


Anime:Drugs would be cheaper.
Rickmeister
Rickmeister
I would go for SI_78''s suggestion.. and the best with that is the greater challenge trying to write it..

ogg-vorbis is better to use than mp3.. I would go for that.. More about ogg vorbis can be found here
role
role
yup midi is the best, but i want more than midi music
i want really music...
so java can play mp3, humm but how to use it?
i just want to use standard j2se for my game
do not want any other plug-in
(coz it''ll be too complicated for player,
if they have to install jre and also jmf to play my game)
is there any other way to play .mp3 without jmf (Java Media Framework)
or how to play .ogg in java??? in code plzz

thanxxx
role
role
thanxx, but i have used javazoom javalayer
it supports .mp3 and only takes 10 megs memory usage to play one full .mp3 song
(compare to half cut .au that i played before that takes 30 megs, it''s marvelous)
but i''ll take a look at that site
maybe i can use .ogg instead .mp3

umm why .ogg is better to use than mp3 Rickmeister??
and where to find and create that .ogg files?
Rickmeister
Rickmeister
quote:
Posted by role
umm why .ogg is better to use than mp3 Rickmeister??
and where to find and create that .ogg files?



It's not "better" in that way.. But it's open source..

All you want to know about it is on display at www.vorbis.org

#define  Email Lex & Yacc Function Pointers Virtual Terrain Knowledge Base Real Programmers
"Evolution is NOT a mistake"

[edited by - Rickmeister on February 24, 2003 6:17:50 AM]
Kentaro
Kentaro
Well, Ogg Vorbis keeps claiming their encoding is better than MP3 in actual sound quality. You should probably compare both yourself and see.

Also, MP3 does have a patent on it. Yes, you can't sell MP3's without paying some guy whose name starts with an 'F'. You can do whatever you want with OGG files, AFAIK.

EDIT: BTW, MP3 has been DROPPED from the Java Media Framework. I found that to be a nice incentive to look up information on Ogg Vorbis.

This isn't life in the fast lane, it's life in the oncoming traffic.
-- Terry Pratchett

[edited by - Kentaro on March 1, 2003 9:33:53 PM]
Over the centuries, mankind has tried many ways of combating the forces of evil...prayer,fasting, good works and so on. Up until Doom, no one seemed to have thought about thedouble-barrel shotgun. Eat leaden death, demon... -- Terry Pratchett
Xai
Xai
note, mp3 or not, you definately want to learn to stream your music anyway ... write a simply sound manager class, that loads up the first segment of oncoming music in memory, and frees up outgoing (old, nonactive i mean) buffers. Then make your stream class manage it''s buffers automatically.
role
role
okay anyone know how to play Ogg Vorbis in java??
only the basic play, loop and stop method
i can''t find that stuff even i rip the entire code

and yup it seems Ogg better than MP3 in games
Kentaro
Kentaro
There are a few options:

VorbisSPI is an actual SPI that you can attach to the Java Media Framework. I think that might be overkill.

JOrbis is an Ogg Vorbis decoder written in pure Java. I think this might be what you need but I don''t know.

Google for some stuff and see what you come up with.


This isn''''t life in the fast lane, it''''s life in the oncoming traffic.
-- Terry Pratchett
Over the centuries, mankind has tried many ways of combating the forces of evil...prayer,fasting, good works and so on. Up until Doom, no one seemed to have thought about thedouble-barrel shotgun. Eat leaden death, demon... -- Terry Pratchett
role
role
cool, i use jorbis and it works very nice (but i don''t know to loop the music)

oh yeah, do u know what''s the best mp3 to ogg converter
i have tried several converter, but it didn''t work well
maybe i have to convert mp3 to wav first, instead directly convert mp3 to ogg?

okay thank you very much guys
mill-o
mill-o
mp3-playback using javazoom javalayer is too slow in games; makes the game lag every five seconds or slow (sounds like a gc problem)

currently i ship mp3 files with my game and use the converter in javalayer to convert it into wav and then play it.

it works, but it''s not perfect.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.