Module sound

Source
Expand description

Sound-related functions. It can beep, play wav files, or convert text to speech.

Note that all methods of the module spawn system processes and return std::process::Child objects. The methods are asynchronous (they return immediately after child process was spawned, without waiting for its completion), but you can call wait() on the returned result.

§Examples

use ev3dev_lang_rust::sound;

// Play "bark.wav", return immediately:
sound::play("bark.wav")?;

// Introduce yourself, wait for completion:
sound::speak("Hello, I am Robot")?.wait()?;

Functions§

beep
Call beep command.
beep_args
Call beep command with the provided arguments.
get_volume
Gets the current sound volume by parsing the output of amixer get <channel>. It tries to determine the default channel by running amixer scontrols. If that fails as well, it uses the Playback channel, as that is the only channel on the EV3.
get_volume_channel
Gets the current sound volume by parsing the output of amixer get <channel>.
play
Play wav file
set_volume
Sets the sound volume to the given percentage [0-100] by calling amixer -q set <channel> <pct>%. It tries to determine the default channel by running amixer scontrols. If that fails as well, it uses the Playback channel, as that is the only channel on the EV3.
set_volume_channel
Sets the sound volume to the given percentage [0-100] by calling amixer -q set <channel> <pct>%.
speak
Speak the given text aloud.
tone
Play tone sequence. The tone_sequence parameter is a list of tuples, where each tuple contains up to three numbers. The first number is frequency in Hz, the second is duration in milliseconds, and the third is delay in milliseconds between this and the next tone in the sequence.
tone_sequence
Play tone sequence. The tone_sequence parameter is a list of tuples, where each tuple contains up to three numbers. The first number is frequency in Hz, the second is duration in milliseconds, and the third is delay in milliseconds between this and the next tone in the sequence.