Sound#
Introduction#
The VEX IQ (2nd gen) Brain can produce audio through its built-in speaker using methods from the Sound category, which play preloaded sound effects or musical notes.
For the examples below, the constructed Brain includes access to the Sound methods and will be used in all subsequent examples throughout this API documentation when referring to those methods.
Below is a list of all methods:
Actions — Play sounds from the Brain.
play_sound— Play a preset sound from the Brain.play_note— Play a musical note from the Brain.sound_off— Stop the currently playing sound.
Actions#
play_sound#
play_sound plays one of the brain’s built-in sounds.
Usage:
brain.play_sound(sound)
Parameter |
Description |
|---|---|
|
The specified sound to play from the brain. |
Sound Name |
Play Sound |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Play the TADA sound from the brain
brain.play_sound(SoundType.TADA)
play_note#
play_note plays a specific note for a specific duration in milliseconds.
Usage:
brain.play_note(octave, note, duration)
Parameters |
Description |
|---|---|
|
Either the low or high octave:
|
|
The note to play:
|
|
Optional. The duration in milliseconds to play the note for, to a max of 500 milliseconds. If no duration is provided, the default duration is 500 milliseconds. |
# Play a quarter note C and half note F
brain.play_note(4, 0, 250)
brain.play_note(4, 3, 500)
sound_off#
sound_off stops a sound that is currently playing.
Usage:
brain.sound_off()
Parameters |
Description |
|---|---|
This method has no parameters. |
# Stop any sound that is playing on the brain
brain.play_sound(SoundType.POWER_DOWN)
wait(0.2, SECONDS)
brain.sound_off()