• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Florian22222

Sound isn´t playing

3 posts in this topic

Hi!
I´ve tried to use the simple sound-API of java.

[CODE]
File f = new File( "menu_sound.wav" );
AudioClip sound = null;
try {
sound = Applet.newAudioClip( f.toURL() );
} catch (MalformedURLException ex) {
Logger.getLogger(SoundTest.class.getName()).log(Level.SEVERE, null, ex);
}
sound.play();
try {
Thread.sleep( 100000 );
} catch (InterruptedException ex) {
Logger.getLogger(SoundTest.class.getName()).log(Level.SEVERE, null, ex);
}
[/CODE]

there is no error but i cant hear any sound.

Please help me ;)
0

Share this post


Link to post
Share on other sites
It wont throw any errors even if the file does not exist. .toURL() is also depricated you should use f.toURI().toURL()
The Java Sound API is limited and even more limited when you use the Applet code to start it up. You'll get more fine grained control is you use the Sound API [url="http://www.oracle.com/technetwork/java/index-139508.html"]http://www.oracle.co...dex-139508.html[/url]

However, most of the APIs like the Sound API have been neglected for years so they haven't been updated properly to meet todays standards. You'll probably find your wav happens to have one of those settings that the Sound API just doesn't support.

I would suggest looking into a different sound API for Java and avoid using the neglected one. Your code will work fine if you use a midi.

You might look into some of the OpenAL Api's like lwjgl [url="http://lwjgl.org/"]http://lwjgl.org/[/url] which they are more up to date then what comes with java. Though that means you will have to have your app bundle the correct native libraries for the supported systems.
0

Share this post


Link to post
Share on other sites
Finally it runs, but if I implement it in my game, I can´t hear the sound(it´s not muted^^)
But if my team leader runs it, he hears the sound.
Did anyone ever have this issue?

EDIT: team member, not leader. I am the leader xD
0

Share this post


Link to post
Share on other sites
First thing is to strip out that Applet code you have sitting their. It's the culprit in catching the errors so you don't see them. Which makes since because Applets were intended to access data only from a web server and never from the client side machine so it should have been made to handle the errors a little and expect that the audio isn't always there. Try something more like this.

[CODE]
import com.sun.media.sound.JavaSoundAudioClip;
import java.io.File;
import java.io.FileInputStream;
public class Test {
public static void main(String args[]) {
File f = null;
FileInputStream in;
try {
f = new File("C:\\AudioTestFolder\\WindowsBalloon.wav");
//mario.mid
//WindowsBalloon.wav
in = new FileInputStream(f);
JavaSoundAudioClip ac = new JavaSoundAudioClip(in);
ac.play();
} catch (java.io.IOException e) {
System.out.println("IO Exception in: " + f.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
}
[/CODE]

This code actually throws errors so you can get better information on what's happening. I'm honestly getting the same issue with the WindowsBalloon.wav that comes with Windows 7, but it works fine with the mario.mid.

The error is
[CODE]
java.io.IOException: Unable to create AudioClip from input stream
at com.sun.media.sound.JavaSoundAudioClip.<init>(JavaSoundAudioClip.java:114)
at Test.main
[/CODE]
But if the file name is wrong the error is this
[CODE]
java.io.FileNotFoundException: C:\XXX\Windows Balloon.wav (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Test.main
[/CODE]

If you're getting the first error you might try encoding the wav file and try something a little more primitive in the wave settings.

What's occurring is Java is trying to use some native code in order to play the file. If some assumptions that the native code is making about the OS is in fact wrong then it will fail. In fact the "Source Code" for where your error is most likely occuring at looks like this.

[CODE]
private boolean createSourceDataLine() {
//compiled code
throw new RuntimeException("Compiled Code");
}
[/CODE]

Which was Sun's way of say Good Luck if this doesn't work.

Like I said before the Sound API is neglected so it tends to have some odd side effects.

I bet you that ether your boss maybe running ether a different OS or a different JVM. There is the possibility of him having the same OS and JVM and then the cause would be a tiny difference in the Audio Drivers he has loaded vs the ones you have loaded, but I doubt that is the case.

PS
[url="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6251460"]http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6251460[/url]
[url="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070730"]http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070730[/url]

The bug you're probably hitting has been around sing Java 1.4 and I tested it with 1.6 and 1.7 and they are still there so its been known about for a long time and has yet to really be fixed.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0