|
|
| Line 231: |
Line 231: |
| | |<syntaxhighlight lang="ROBOTC"> | | |<syntaxhighlight lang="ROBOTC"> |
| | PlaySound(soundBeepBeep); // play the sound, 'soundBeepBeep' | | PlaySound(soundBeepBeep); // play the sound, 'soundBeepBeep' |
| − | </syntaxhighlight>
| |
| − | |-
| |
| − | |}
| |
| − | |-
| |
| − | |}
| |
| − | <br />
| |
| − |
| |
| − | == PlaySoundFile ==
| |
| − | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
| |
| − | |-
| |
| − | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">PlaySoundFile</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">const string </span><span class="bigCodeBasic">&sFileName</span><span class="bigCodePunc">)</span>
| |
| − | |-
| |
| − | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Plays a sound file from the NXT file system. File must be present on the NXT. RobotC will automatically download required files with user program.
| |
| − | |-
| |
| − | |
| |
| − | {| class="parameterTable" cellpadding="5%" width="100%"
| |
| − | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter
| |
| − | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation
| |
| − | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type
| |
| − | |-
| |
| − | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''sFileName''
| |
| − | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A sound file to play
| |
| − | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_string|string]]
| |
| − | |-
| |
| − | |}
| |
| − | |-
| |
| − | |
| |
| − | {|
| |
| − | |-
| |
| − | |<syntaxhighlight lang="ROBOTC">
| |
| − | PlaySoundFile("Woops.rso"); // play the sound file, 'Woops.rso'
| |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |
| 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.
|