Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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  
  Need a work around - 1.5 issue  (Read 1270 times)
0 Members and 1 Guest are viewing this topic.
Offline wjp

Senior Newbie




Java games rock!


« Posted 2005-03-24 06:55:40 »

Hello,
this is my first post on this forum - only just found it - I shall be around more now!!
Anyhow to my issue.

You may or may not be aware of this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070730
which is meant to be fixed. However with my game it doesn't appear to be fixed Angry .

I'm using the classic Applet.getAudioClip which has been working great is earlier JVM's. My issue is that I need to play many short clips very very close together (for example balls breaking in a game of pool). Currently you are either hear silence or the occasionaly sound clip.

Reading the bug report (thats meant to be fixed but is'nt) - there is a work around using java sound (Mixers,Clip,Line,etc) - however I need to emulate the behaviour of the classic Applet.getAudioClip . - this is great as AudioClip.play() is asyncronous - every time I call it returns immeadiatly and every time I call the same instance again - it plays another sound. I find with java sound this doesn't seem possible .

Any ideas on how I can fixed my issue?

thanks.
Offline Malohkan

Senior Devvie




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


« Reply #1 - Posted 2005-03-25 21:25:31 »

I use the Clip class.  I decode .ogg's into a byte[], and then use:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
AudioFormat audioFormat = new AudioFormat(
      rate,
      16,
      channels,
      true,  // PCM_Signed
      false  // littleEndian
);

DataLine.Info info = new DataLine.Info(
      Clip.class,
      audioFormat
);
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(audioFormat, audio, 0, size);
clip.stop();

To load it into memory.  When you want to play it, use:
clip.start();
To reset it, use clip.stop(); if you haven't already or it hasn't played through on its own, then clip.setFramePosition(0);

I hope that's enough to get you started Smiley  Let me know if you have more questions.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline wjp

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-03-29 05:55:15 »

HI,
thanks for that!. I'll try this later tonight.
Quick question though - is the synchronous or asynchronous? when you call clip.start() does it reutn immeadiatly or after its finshed?

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

toopeicgaming1999 (69 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (13 views)
2014-11-26 15:20:08

SHC (26 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (30 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (54 views)
2014-11-12 21:11:50
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!