#### Archived

This topic is now archived and is closed to further replies.

# [java] Java sound?? Does it even exist

This topic is 5573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Am I going crazy, or does java completely lack in the sound department? Ok, ok, I know it''s there, but I''m having one heck of a time getting to it. What I''ve got is something like this:

Applet tempApplet = new Applet();

{
AudioClip ac;
ac = Applet.getSound(getCodeBase(),soundName+".wav");
return ac;
}

public void playSound(AudioClip ac)
{
ac.Play();
}

If I do this or something similar, I get it to compile and run fine, execpt no sound, or if I use slightly different methods, I get an incorect format error. Basically I''m looking for either some tuts or someone to tell me howw to chage the format. By the way I have looked and the javagaming tutorials for this, but I just want something as simple as possible and easy to understand. THanks a ton.

##### Share on other sites
No, Java does have sound capabilities. I''ve never worked with them myself. My partner actually put together some voice recognition code in Java that accessed a database upon verbal command. It was pretty cool, but it wasn''t easy. Keep trying. In the meantime, this post I''m making will bump this question back up to the top for you.

Looking for an honest video game publisher? Visit www.gamethoughts.com

##### Share on other sites
I think the sound has to be in .au format. I am not 100% sure about that, but that is the way it has always worked for me. I could never get .wav sounds to play either, but if I converted them to .au they would play. GoldWave is a good free program that can convert wav to au. Good luck!

##### Share on other sites
If you had visited Google and searched for Java Sound you would have found this was the first result.

##### Share on other sites
quote:
Sun''s reference implementation for the Java Sound API, also known as the Java Sound engine, is a 64 channel audio rendering and MIDI controlled sound synthesis engine which offers reliable, high quality sound on all JavaTM 2 Platforms. This implementation also supports a set of high-quality General MIDI sound banks.

Nice try, oh wise one, but I don''t think that is what he is looking for, since he mentioned WAV and not MIDI.

##### Share on other sites
quote:
Original post by Mr Bakbugawk
Nice try, oh wise one, but I don''t think that is what he is looking for, since he mentioned WAV and not MIDI.

Forgive me good sir, but I assumed that the javax.sound.sampled API would do the trick. Thankfully you''re here to point out my ignorance.

##### Share on other sites
[quote
Nice try, oh wise one, but I don''t think that is what he is looking for, since he mentioned WAV and not MIDI.

What wayfarerX was doing is encouraging Jonbca to use the excellent search facilities that are made available to people (such as google). It helps him/her help him/herself.

On the other hand, you do need to read what''s been posted, not just glance at the first line, and make your own conclusions. In fact, it does say audio playback and recording on the first line and what you quoted wasn''t the first line.

Hope I didn''t come across as being too confrontational.

##### Share on other sites
Since you''re using it in an applet, odds are you''re trying it out under IE, which supports only .AU sound files. It is possible to play .WAV and .MID on the JRE 1.3 (and later), but not on the previous versions (I only use those two sound types on independent programs, since IE has a share of around 90%... at least on the people who visit my sites).

Pedro Amaro (http://pedroamaro.pt.vu)

##### Share on other sites
quote:
Original post by Viro
[quote
What wayfarerX was doing is encouraging Jonbca to use the excellent search facilities that are made available to people (such as google). It helps him/her help him/herself.
Forums, Books and Newspapers are also made available to people...why can''t some people let others try to obtain the information needed in the way they want it? Maybe you like google, maybe he doesn''t. Why don''t we close the forums or simply implement an algorithm that parses the post for some words and then makes an automated reply "use google, type "xxx yyy zzz"...?!?

##### Share on other sites
quote:
Original post by EgonOlsen
Forums, Books and Newspapers are also made available to people...why can't some people let others try to obtain the information needed in the way they want it? Maybe you like google, maybe he doesn't. Why don't we close the forums or simply implement an algorithm that parses the post for some words and then makes an automated reply "use google, type "xxx yyy zzz"...?!?

Information is available on the internet. Load of it even. If you took a look at WayfarerX's post, he posted the direct link to what was asked, and pointed to google, because that's probably where he got the link from. He didn't play the poster down.

As for the original post, he's looking for some tuts, which he clearly got. I know it probably sounds rude and elitist, but you should make an effort to search for stuff, before asking.

EDIT: Found another site using Yahoo that may be off use. JAvasound resources

[edited by - Viro on October 18, 2002 4:10:56 AM]

##### Share on other sites
quote:
If you took a look at WayfarerX's post, he posted the direct link to what was asked

No, he didn't. What he posted was NOT was what asked for.

quote:
I know it probably sounds rude and elitist, but you should make an effort to search for stuff, before asking.

I mean, he had a valid question and even posted some code...what else does one have to do to avoid these "use google" posts?
I suggest this: "Hi, i have 2 questions: 1.) *something* 2.) Why can't i access google at the moment?"

[edited by - EgonOlsen on October 18, 2002 5:26:58 AM]

##### Share on other sites
quote:

No, he didn''t. What he posted was NOT was what asked for.

Fair enough. What kind of information was he looking for then? That page did contain the programmer''s guide, which is what most people (okay, I did, and I''m assuming most people would ) would go through.

quote:

I mean, he had a valid question and even posted some code...what else does one have to do to avoid these "use google" posts?
I suggest this: "Hi, i have 2 questions: 1.) *something* 2.) Why can''t i access google at the moment?"

Perhaps its a cultural thing, and I''m sorry if I''d offended anyone. If my co-workers asked me about something that I think they could have found out on their own, if they had the proper access to the proper tools, I''d point them to what they were looking for, and I''d point them to how I got them. In this case, I''d point them to the Java Sound API homepage, and point them to Google, as that''s how I got it in the first place.

But hey, I''m Chinese. What offends you might not offend me and vice versa. Really sorry about that.

##### Share on other sites
quote:
Original post by Viro
[quote]But hey, I''m Chinese. What offends you might not offend me and vice versa. Really sorry about that.
You haven''t offended me. I just think different, but that''s ok.

##### Share on other sites
I seem to have incited a minor flame fest here . Let me make clear that my original post was not meant to be insulting in any manner. It was a simple statement in response to:
quote:
Original post by Jonbca
Java sound?? Does it even exist

No elitism, no insults, just links. Seriously guys, mellow out.
quote:
Original post by EgonOlsen
Forums, Books and Newspapers are also made available to people...why can't some people let others try to obtain the information needed in the way they want it?

While I respect an individual's right to like and dislike various forms of information, using search engines to find publicly available standard API specifications is a pretty basic skill any programmer should have.
quote:
No, he didn't. What he posted was NOT was what asked for.

The original poster was looking for information on Java Sound APIs and on how to load and play a .wav file. The links I provided contain an extensive overview on exactly how to do this.

[edited by - wayfarerx on October 18, 2002 12:23:38 PM]

##### Share on other sites
Do I have to seperate you or can you children play nice with each other?

##### Share on other sites
quote:
Original post by WayfarerX
I seem to have incited a minor flame fest here
I wouldn''t call this flaming.
quote:
While I respect an individual''s right to like and dislike various forms of information, using search engines to find publicly available standard API specifications is a pretty basic skill any programmer should have.
Agreed, but i was under the impression that it was not his problem to find API-docs. He already has some code, it just doesn''t makes sound.

The problem i''m having with these kind of "google-replies" is, that it is hard to draw the line. When somebody would ask "what is java?" here, then i would agree that he should consult other resources before coming back. In other cases, it''s not so simple. When comes the point, where a post is justified and when do i have to expect "google-replies"??
During my day-work, i noticed the tendency of some people to do "information-hiding" (at least in the IT-industry). Some people seem to think that no one else should know what they do and if it is absolutly required, these people want all other people to go through the same learning process as they did. This is contra-productive IMHO and i don''t understand it. Maybe "google-posts" remind me of that and i may have gone a bit too far.

##### Share on other sites
quote:
Original post by EgonOlsen
Agreed, but i was under the impression that it was not his problem to find API-docs. He already has some code, it just doesn''t makes sound.

Here is where Java''s tendancy to be redundant makes things fishy. The Java Sound API (javax.sound.*) is a completely seperate entity from the Applet API''s AudioClip interface (java.applet.AudioClip). If you''re not forced to use pre-1.3 Java I''d always reccommend learning javax.sound.
quote:
Original post by Michalson
Do I have to seperate you or can you children play nice with each other?

Sorry mom, we''ll be good.