VEX2 Functions Sound
From ROBOTC API Guide
(→bSoundQueueAvailable) |
|||
| (4 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | <yambe:breadcrumb self="Sound">VEX2_Functions_and_Variables|Functions and Variables</yambe:breadcrumb> | |
| − | + | <br /> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
{| class="wikiText" | {| class="wikiText" | ||
| Line 16: | Line 11: | ||
|- | |- | ||
|} | |} | ||
| + | <br /> | ||
| − | + | {{tl|1|1}} | |
| − | { | + | <br /> |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
== bPlaySounds == | == bPlaySounds == | ||
| Line 231: | Line 212: | ||
|<syntaxhighlight lang="ROBOTC"> | |<syntaxhighlight lang="ROBOTC"> | ||
PlaySound(soundBeepBeep); // play the sound, 'soundBeepBeep' | PlaySound(soundBeepBeep); // play the sound, 'soundBeepBeep' | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
Latest revision as of 09:10, 30 April 2012
CORTEX → Functions and Variables → Sound
| ROBOTC provides a comprehensive suite of functions for controlling an optional speaker connected to the first motor port on a VEX controller.
The ROBOTC firmware queues up to 10 sound items for playback. This allows user programs to initiate playback of a sound item and continue execution without having to wait for a sound item to finish; this mode of operation is very desirable for robots where, if you waited for the sound to complete playback, you could be delayed in updating the robot’s motors in reaction to a change in sensors. There are several sample programs illustrating sound playback on a VEX controller. The file “songs.c” contains several complete songs that can be played as a background task while your robot continues to execute its main “mission” task. |
|
| |||||||
bPlaySounds
| word bPlaySounds | |
| (word) Boolean flag. Indicates whether new sound requests should be accepted or discarded. Note that this is defined as a word but is treated as a bool. | |
|
bSoundActive
| const bool bSoundActive | |
| (bool) Boolean flag. If true indicates sound system is actively playing sound. | |
|
bSoundQueueAvailable
| const bool bSoundQueueAvailable | |
| (bool) Boolean flag. Indicates whether there is space available in the sound queue for another item. | |
|
ClearSounds
| void ClearSounds() | |
| (void) Clears all existing and buffered sound commands. | |
|
MuteSound
| void MuteSound() | |
| (void) Mutes all subsequent sound commands. | |
|
nVolume
| word nVolume | |
| (word) Sound volume. Range 0 to 4 (loudest). | |
|
PlayImmediateTone
| void PlayImmediateTone(const int frequency, const int durationIn10MsecTicks) | |||||||||
| (void) Immediately play tone at frequency & duration ahead of queued requests. | |||||||||
| |||||||||
|
PlaySound
| void PlaySound(TSounds sound) | ||||||
| (void) Play one of the system predefined sounds (buzz, beep, click, ...) | ||||||
| ||||||
|
PlayTone
| void PlayTone(const int frequency, const int durationIn10MsecTicks) | |||||||||
| (void) Plays a constant tone at the specified frequency and duration. | |||||||||
| |||||||||
|
UnmuteSound
| void UnmuteSound() | |
| (void) Restores sound playback volume. | |
|