Module ev3dev_lang_rust::sound[][src]

Expand description

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

Note that all methods of the meodule 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

Call beep command.

Call beep command with the provided arguments.

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.

Gets the current sound volume by parsing the output of amixer get <channel>.

Play wav file

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.

Sets the sound volume to the given percentage [0-100] by calling amixer -q set <channel> <pct>%.

Speak the given text aloud.

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.

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.