Jump to content
  • Advertisement

Archived

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

lupine

[java] Sa..Sa...Sound

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

You mean to tell me that there is not sound in Java 1.1 without a special plugin? I hope this is not entirely true, what kind of sound files/formats are compatable with Java 1.1 Thanks you, weekend have that

Share this post


Link to post
Share on other sites
Advertisement
If it's an applet use play() or getAudioClip() in Applet. If it's an app use Applet.newAudioClip(). I think it only supports au files in 1.1. May use wav too. Don't know. I always give up before I add sound to my games.

Oh crap, that newAudioClip method is 1.2 only. Oops. Disregard

But why would you write an application in 1.1? The user would have to download a JRE anyway. I guess you could want to take advantage of jview.exe that everyone with IE has...

There are that com.sun.audio package though...

Edited by - buh on June 8, 2001 11:41:16 PM

Edited by - buh on June 8, 2001 11:44:16 PM

Edited by - buh on June 10, 2001 1:35:46 PM

Share this post


Link to post
Share on other sites
Thanks for the pointers,
using 1.1 for maximum portability

I will check out com.sun.audio (is that 1.1 ?)

I am familiar with .wav , what is "au" is that higer quality then .wav?

thanks all

Share this post


Link to post
Share on other sites
Nope, .au files are crap. Actually I can't really hear any difference. Probably just not compressed as well. Don't see them around nowadays.

Sorry, guess it's just sun.audio. Using this little package kinda defeats the maximum portability thing though. It'll only work with Sun's 1.1 JRE. It'd probably be better to just use 1.3 or 1.4.

Edited by - buh on June 11, 2001 1:51:08 PM

Share this post


Link to post
Share on other sites
so, is the verdict .wav files only in Java 1.1?

I wonder what would be involved in writing a player
myself?

Has anyone tried this?

Share this post


Link to post
Share on other sites
The sun audio class can be used in 1.0 and 1.1

By using it you are not being 100% platform transperent aparently but I have had no problems with it....

I posted this ages ago....

import sun.audio.*;

Variables
byte play_snd_data[]; remember to fill it with something!
AudioData snd_audio;
AudioDataStream snd_stream;

to play
snd_audio = new AudioData(play_snd_data);
snd_stream = new AudioDataStream(snd_audio);
AudioPlayer.player.start(snd_stream);

to stop
AudioPlayer.player.stop(snd_stream);

and there is a method to play looping to



Share this post


Link to post
Share on other sites
Thanks Chaos, that helps

What kind of audio files will it play?

I am assuming this will work in an app?

Thanks for all your help.

Share this post


Link to post
Share on other sites
By default the JDK 1.1 sound API supports only the .AU (u-law compressed) format. But the nice thing is that if you use the "official hack" shown by Chaoslab, you are accessing some of the internal classes and you can implement support for other formats.

See how I''ve implemented .WAV support in my GameFrame for Java library (goto downloads section and download the 0.9.5 version).

The source code of interest can be found in source file src/gameframe/implementations/jdk11x/CSoundEngine.java

The loadSample method loads a WAV file and converts it to a format that is understood by the JDK 1.1 internal sound mixer. The SoundStream, LoopingSoundStream, RiffWavFile and ULawEncoder classes are used in the process.

Share this post


Link to post
Share on other sites
quote:
Original post by javanerd

By default the JDK 1.1 sound API supports only the .AU (u-law compressed) format. But the nice thing is that if you use the "official hack" shown by Chaoslab, you are accessing some of the internal classes and you can implement support for other formats.




I''m confused, what other formats?

So, Chaoslab''s example is an "official hack" of sun.audio?
Are there any pitfalls, do I need to worry about soundbank or anything like that?

I really appreciate everyones help 8)

Share this post


Link to post
Share on other sites
Well I don''t believe any hack is official!

;-)

I have read that it is not considered "pure java" but I have had no problems with it and I have a suspition that it''s what the applet.audioclip use''s anyway.

The only prob is you have to create the sounds from byte buffers (as you can see) which takes a bit more effort, but hay that also meens you can apply algorythms to them.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!