uwcse.io
Class Sound

java.lang.Object
  |
  +--uwcse.io.Sound

public class Sound
extends java.lang.Object

A simple sound class. Sounds can be played using the AudioPlayer class. Sounds can come from files or from URLs (web addresses). At least .wav, and possibly other formats, are supported.


Constructor Summary
Sound(java.lang.String fileName)
          Create a new sound, loading from the given filename.
Sound(java.net.URL url)
          Create a new sound, loading from the given URL.
 
Method Summary
 java.applet.AudioClip getClip()
          Answer the AudioClip for this sound.
 void loop()
          Play the sound repeatedly, until told to stop.
 void play()
          Play the sound once, or until told to stop.
 void stop()
          Stop playing the sound.
static void test()
          A test method that repeatedly asks for a URL and then plays the sound given
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sound

public Sound(java.lang.String fileName)
Create a new sound, loading from the given filename.

Sound

public Sound(java.net.URL url)
Create a new sound, loading from the given URL. Check out e.g. www.wavcentral.com, www.dailywav.com, or new.wavlist.com, or what you find from doing a search for "wav files", for sample .wav files on the net.
Method Detail

getClip

public java.applet.AudioClip getClip()
Answer the AudioClip for this sound. (For internal use by the AudioPlayer class.)

loop

public void loop()
Play the sound repeatedly, until told to stop.

play

public void play()
Play the sound once, or until told to stop.

stop

public void stop()
Stop playing the sound.

test

public static void test()
A test method that repeatedly asks for a URL and then plays the sound given