Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (595)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  mp3's  (Read 1882 times)
0 Members and 1 Guest are viewing this topic.
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Posted 2004-07-09 02:21:39 »

I got JLayer to try to help me load in my MP3 clips and with much tinkering I was able to get a Player or an AdvancedPlayer created.  I held on to my byte[]'s so that I could re-create Player's when I wanted to play the sounds multiple times, but it was very slow.

I've read through threads here talking about creating a Clip with a byte[] to play and that that's fast, but to do that you need the appropriate AudioFormat to make it work, and I can't figure out how to get that.  I've looked through all the classes in JLayer and I can't find anything to help me.

I tried looking at JOrbis and it was so ugly to read my eyes hurt looking at the code.  Same result with their webpage.  So no luck there either.

Could anyone give me some advice on how to get some audio playing at practical speeds?  Thanks!

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Reply #1 - Posted 2004-07-09 14:34:14 »

Well I've found how to get an AudioFormat, but for some reason I can't get it working still:
InputStream inputstream = url.openStream();
BasicMP3FileReader mp = new BasicMP3FileReader();
audioInputStream = mp.getAudioInputStream(inputstream);
javax.sound.sampled.UnsupportedAudioFileException: incorrect magic number 1228931072

This will give me a working Player:
InputStream in = audioURL.openStream();
AudioDevice dev = FactoryRegistry.systemRegistry().createAudioDevice();
Player player = new Player(in, dev);
But with that I can never get an AudioFormat out of it.  So to sum it up, I think I may have gotten closer but it still doesn't work.

This is strange, it seems Flash can do short and long sounds beautifully in a web page, but I haven't heard of anyone managing it in a Java Applet.  Surely Java isn't outdone by Flash is it?  Hopefully help for me is on its way!

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline PunkerBitches

Innocent Bystander

Java games rock!

« Reply #2 - Posted 2004-07-25 19:02:13 »

I don't  know if you want to play your audio in an applet or in a stand alone application ... if you want to play your audio in an applet you can use the interface AudioClip from the package java.applet

AudioClip soundToPlay;

soundToPlay = getAudioClip( getCodeBase(), "nameofthefile.wav");;

Hope it help you.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Reply #3 - Posted 2004-07-26 03:26:25 »

I have played with AudioClips, but my real desire is to read in mp3's.  If I can get them in as AudioClips I'll be happy with that.  Perhaps the mp3 format isn't even the way I should go?  Is there a better format I should be using that can compress well but is still widely and easily used in Java?

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #4 - Posted 2004-07-26 10:26:59 »

Yes, ogg vorbis. It's royality free and there is also a nice library. And besides it sounds much better than mp3 especially with low bitrates.


an encoder is here:

simple to use: (oggdropXPd)

弾幕 ☆ @mahonnaiseblog
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Reply #5 - Posted 2004-07-26 12:25:41 »

Thanks!  I'll check that out

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline Bombadil

Senior Devvie

« Reply #6 - Posted 2004-07-27 06:20:21 »

Yes, Ogg is a good audio format.
It's been used by a few commercial games and it's being used by the masters of gaming 3d graphics, ID, for their Doom3 (see here).
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

deepthought (47 views)
2015-06-30 15:39:44

deepthought (50 views)
2015-06-30 15:39:09

deepthought (62 views)
2015-06-30 15:36:52

Za\'Anzabar (36 views)
2015-06-29 05:44:54

TritonDreyja (46 views)
2015-06-24 17:10:40

CopyableCougar4 (46 views)
2015-06-23 00:34:45

BurntPizza (51 views)
2015-06-21 20:36:46

cookiecompiler (93 views)
2015-06-11 15:42:53

cookiecompiler (55 views)
2015-06-11 15:41:14

NegativeZero (80 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!