[java] Sa..Sa...Sound

Started by
14 comments, last by lupine 22 years, 10 months ago
quote:Original post by Chaoslab

Well I don''t believe any hack is official!
;-)
hay that also meens you can apply algorythms to them.


Nice! so this code:

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);


will enable me to play .wav files,and I could add a loop
I just got clearence from the sound and music guy to use
.wav files. I am assuming I will be able to play multiple
tracks simultaneously if I code it correctly?

Thanks All!



"do you like my helmut?"-yoghurt
Advertisement
Yes you can play multiple sounds con currently but don''t play to many as it can sound a bit crusty!

Of course if you like crust (And I don''t really mind it!)

Then all is good anyway!

:-)

ujhkfkfk
I owe you one Chaoslab


8) Robert Corrina
mailto:robertcorrina@patownsend.com



"do you like my helmut?"-yoghurt
quote:Original post by lupine
I''m confused, what other formats?

Sorry I wasn''t too clear on that. My post meant that you can write your own loader for any format.

One way to do this is to write your own AudioDataStream implementation that converts the audio format from the loaded format to U-law format (that JDK 1.1. understands) and then feeds JDK 1.1 audio engine with this stream.

JDK 1.1 doesn''t support WAV by itself. That''s why I pointed out the library code, because there you can see how I''ve implemented the conversion from WAV to AU upon loading the file. Also I''ve implemented a looping sound stream that allows me to loop the sound as needed.
-Pasi Keranen
Do be careful using the sun.audio.* classes, they don''t work under java 1.3.
So it might be worth doing some checking to see if the relevant classes exist at runtime or not. You should be able to do a bit of cunning introspection/reflection to do this. That way people can still play the game, but they might not have any sound, which is better than it crashing.

John
Thanks for the information nerd 8)
Sounds like I'm gonna have to get a little fancy
to code this functionality. I feel squemish about
using outside libraries.

Thanks for the heads up lil'
Looks like I'll do a 1.1 with dodge(error handling)
and then I'll follow up with a different version
for 1.3 and beyond
This brings me to my distribution questions
I hope I can count on all your help in my next thread
8)



Edited by - lupine on June 15, 2001 3:22:37 PM
"do you like my helmut?"-yoghurt

This topic is closed to new replies.

Advertisement