Sound

open class Sound

Class that interfaces with the SoundPlayer to create and broadcast sound files on the Driver Station.

All sounds played through this class are proxied via the SoundPlayer class, accessed on the play call. Sound files can be stored in the res/raw folder of the project, and can be retrieved using your R class.

Author

Lucas Bubner, 2024

Since

6.1.0

See also

SoundPlayer

Constructors

Link copied to clipboard
constructor(file: File)
Create a new Sound file with the given file.
constructor(@RawRes resourceId: Int)
Create a new Sound file with the given resource ID.

Functions

Link copied to clipboard
open fun onEnd(action: Runnable): Sound
Set the action to run when the sound ends.
Link copied to clipboard
open fun onStart(action: Consumer<Integer>): Sound
Set the action to run when the sound starts.
Link copied to clipboard
open fun play()
Sends this sound to the Driver Station to be queued and played with the set parameters once.
open fun play(times: Int)
Sends this sound to the Driver Station to be queued and played with the set parameters now.
Link copied to clipboard
open fun playForever()
Sends this sound to the Driver Station to be queued and played with the set parameters infinitely.
Link copied to clipboard
open fun setRate(rate: Double): Sound
Set the playback rate of the sound.
Link copied to clipboard
open fun setVolume(volume: Double): Sound
Set the volume of the sound.
Link copied to clipboard
open fun setYielding(wait: Boolean): Sound
Whether to wait for currently playing non-looping sounds to finish before playing this sound.