Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
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 1725 times)
0 Members and 1 Guest are viewing this topic.
Offline Malohkan

Senior Duke




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
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline Malohkan

Senior Duke




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:
1  
2  
3  
InputStream inputstream = url.openStream();
BasicMP3FileReader mp = new BasicMP3FileReader();
audioInputStream = mp.getAudioInputStream(inputstream);
Yields
javax.sound.sampled.UnsupportedAudioFileException: incorrect magic number 1228931072

This will give me a working Player:
1  
2  
3  
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
GameLizard.com
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");

soundToPlay.play();


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

Senior Duke




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
GameLizard.com
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.

http://www.jcraft.com/jorbis/

edit:

an encoder is here:
http://www.vorbis.com/download.psp

simple to use:
http://www.vorbis.com/download_win.psp (oggdropXPd)

弾幕 ☆ @mahonnaiseblog
Offline Malohkan

Senior Duke




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
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline Bombadil

Senior Duke





« 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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (32 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
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!