Package ch.epfl.cs107.play.window.swing
Class SwingSound
java.lang.Object
ch.epfl.cs107.play.window.swing.SwingSound
- All Implemented Interfaces:
Sound
-
Constructor Summary
ConstructorsConstructorDescriptionSwingSound(InputStream input) Default SwingSound Constructor - store the input stream into an audio byte array - keep also format, info and size in memory -
Method Summary
Modifier and TypeMethodDescriptionopenedClip(int offset) Create and open a new audio Clip containing the swing soundintCompute a random integer in the range defined by the sound size
-
Constructor Details
-
SwingSound
Default SwingSound Constructor - store the input stream into an audio byte array - keep also format, info and size in memory- Parameters:
input- (InputStream): corresponding to the sound file. Not null- Throws:
IOException- : if the AudioInputStream cannot be readUnsupportedAudioFileException- : if the URL does not point to valid audio file data recognized by the system
-
-
Method Details
-
openedClip
Create and open a new audio Clip containing the swing sound- Parameters:
offset- (int): the point at which to start copying, expressed in bytes from the beginning of the array- Returns:
- (Clip): the opened swing sound ready to start or null on error
-
randomOffSet
public int randomOffSet()Compute a random integer in the range defined by the sound size- Returns:
- (int): a random int between 0 (inclusive) and size (exclusive)
-