trait Sound extends AnyRef
Each instance of this trait represents a recorded sound sample.
You create Sound
s with the methods on the companion object: Sound("my_sound_file.wav")
.
The supported formats are WAV, AIFF, AU, AIFC, and SND.
This trait has an alias in the top-level package o1, so it’s accessible to
students simply via import o1._
.
This type is essentially a wrapper around the key functionality in javax.sound.Sampled, especially its Clip class.
- Alphabetic
- By Inheritance
- Sound
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract val description: String
A description of the sound’s origin.
A description of the sound’s origin. Examples:
"file:/D:/O1Course/Pong/bin/sounds/slap.wav"
"http://www.aalto.fi/does_not_exist.wav (failed to create)"
- abstract def isDefined: Boolean
whether the
Sound
object represents a successfully loaded sound sample.whether the
Sound
object represents a successfully loaded sound sample. This will betrue
if the methods on the companion object successfully loaded the sound from a file or a URL, andfalse
if there was a problem - abstract def play(repeats: Int = 0, volume: Float = this.volume): Unit
Plays the sound sample, possibly multiple times in sequence.
Plays the sound sample, possibly multiple times in sequence.
- repeats
how many additional times the sound should play after being played once; if you pass in KeepRepeating, the sound will repeat indefinitely unless stop is called
- volume
you may pass in a number to override the sounds’s default volume adjustment
- abstract def stop(): Unit
Stops the playing of the sound sample, previously started with play.
- abstract val volume: Float
an adjustment to the loaded sound sample’s volume: a positive number makes it louder a negative one quieter.
an adjustment to the loaded sound sample’s volume: a positive number makes it louder a negative one quieter. A value equal to Mute means the sound is completely silent.
- abstract def withVolume(differentVolume: Float): Sound
Returns an other
Sound
otherwise identical to this one but with the given volume adjustment.
Concrete Value Members
- def toString: String
A
String
representation of the sound; equals description.A
String
representation of the sound; equals description.- Definition Classes
- Sound → AnyRef → Any