Sonido#
Introducción#
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.
Para los ejemplos a continuación, el cerebro construido incluye acceso a los métodos de sonido y se utilizará en todos los ejemplos posteriores en esta documentación de API cuando se haga referencia a esos métodos.
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.
Comportamiento#
play_sound#
play_sound plays one of the brain’s built-in sounds.
Usage:
brain.play_sound(sound)
Parámetro |
Descripción |
|---|---|
|
El sonido especificado que debe reproducirse desde el cerebro. |
Nombre del sonido |
Reproducir sonido |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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)
Parámetros |
Descripción |
|---|---|
|
Either the low or high octave:
|
|
The note to play:
|
|
Opcional. La duración en milisegundos de la reproducción de la nota, hasta un máximo de 500 milisegundos. Si no se especifica ninguna duración, la duración predeterminada es de 500 milisegundos. |
# 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()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Stop any sound that is playing on the brain
brain.play_sound(SoundType.POWER_DOWN)
wait(0.2, SECONDS)
brain.sound_off()