update links
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
FTC Blocks can play short sounds on Robot Controller (RC) phones and Driver Station (DS) devices. Here's a general guide to this fun and useful feature.
|
FTC Blocks can play short sounds on Robot Controller (RC) phones and Driver Station (DS) devices. Here's a general guide to this fun and useful feature.
|
||||||
|
|
||||||
A [different tutorial](https://github.com/WestsideRobotics/FTC-DS-Speech/wiki) covers Text-to-Speech Telemetry that plays only on the DS phone or Driver Hub -- also a fun and useful feature.
|
A [different FTC Wiki tutorial](https://github.com/FIRST-Tech-Challenge/FtcRobotController/wiki/Driver-Station-Speech-Telemetry) covers Text-to-Speech Telemetry that plays only on the DS phone or Driver Hub -- also a fun and useful feature.
|
||||||
|
|
||||||
## Step 1 - Audio Files
|
## Step 1 - Audio Files
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ A timed pause is essential if a sound plays in a tight loop. The audio file wil
|
|||||||
|
|
||||||
Even if a **gamepad button** triggers playback in a repeat loop, a pause is still needed. The loop cycles faster than a human can release the button, causing that staccato of repeated starts. A "backlog" of waiting playbacks can build up; the sounds may continue spilling out long after the button has been released. Eventually the queued files will all play, and the sounds will stop.
|
Even if a **gamepad button** triggers playback in a repeat loop, a pause is still needed. The loop cycles faster than a human can release the button, causing that staccato of repeated starts. A "backlog" of waiting playbacks can build up; the sounds may continue spilling out long after the button has been released. Eventually the queued files will all play, and the sounds will stop.
|
||||||
|
|
||||||
The timed pause can be done with **sleep()** as shown below, or with a **custom timer**. A tutorial on Blocks timers is [here](https://github.com/WestsideRobotics/FTC-Timers/wiki).
|
The timed pause can be done with **sleep()** as shown below, or with a **custom timer**. An FTC Wiki tutorial on Blocks timers is [here](https://github.com/FIRST-Tech-Challenge/FtcRobotController/wiki/Timers-in-FTC-Blocks).
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0180-gamepad-loop.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0180-gamepad-loop.png|]]<p>
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ The **.stop** command simply stops a currently playing sound file. It does not
|
|||||||
|
|
||||||
Sound files are stored on the RC device, in a folder named FIRST/blocks/sounds. Here you will see all the files from the My Sounds listing.
|
Sound files are stored on the RC device, in a folder named FIRST/blocks/sounds. Here you will see all the files from the My Sounds listing.
|
||||||
|
|
||||||
For spoken audio that plays only on the Driver Hub or DS phone, see this tutorial on [speech Telemetry](https://github.com/WestsideRobotics/FTC-DS-Speech/wiki).
|
For spoken audio that plays only on the Driver Hub or DS phone, see this FTC Wiki tutorial on [speech Telemetry](https://github.com/FIRST-Tech-Challenge/FtcRobotController/wiki/Driver-Station-Speech-Telemetry).
|
||||||
|
|
||||||
Special note... you may find that Android does not load or play the audio files instantly, especially the first time. It takes some practice to determine a file's response characteristics; still there can be unpredictable system-related variation. Consider pre-playing key sounds, for instant response later.
|
Special note... you may find that Android does not load or play the audio files instantly, especially the first time. It takes some practice to determine a file's response characteristics; still there can be unpredictable system-related variation. Consider pre-playing key sounds, for instant response later.
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ For example, a 4-second .wav audio file was reduced from 376 Kb to 18 Kb in .OGG
|
|||||||
|
|
||||||
Some [forums](https://stackoverflow.com/questions/43060791/android-soundpool-can-only-play-6-seconds-mp3) mention keeping the file size under 1 Mb, but apparently the actual limit is 1 Mb of **buffer size** (memory) which is not the same as file size. Over-limit cases are flagged in the log file. In any case SoundPool does **not** have an inherent time limit such as 6 seconds.
|
Some [forums](https://stackoverflow.com/questions/43060791/android-soundpool-can-only-play-6-seconds-mp3) mention keeping the file size under 1 Mb, but apparently the actual limit is 1 Mb of **buffer size** (memory) which is not the same as file size. Over-limit cases are flagged in the log file. In any case SoundPool does **not** have an inherent time limit such as 6 seconds.
|
||||||
|
|
||||||
One FTC team wanted a theme song for autonomous. If the playing time can't be stretched enough, a last resort might be to break up the recording into **several sections** and play them in order. With great care this could be overlaid onto a completed/fine-tuned Linear OpMode autonomous. Or the autonomous could be re-written as a **state machine** in an Iterative OpMode, with the audio clips played in a **timed sequence**. Not so easy but maybe a good programming project! Learn about Blocks timers [here](https://github.com/WestsideRobotics/FTC-Timers/wiki).
|
One FTC team wanted a theme song for autonomous. If the playing time can't be stretched enough, a last resort might be to break up the recording into **several sections** and play them in order. With great care this could be overlaid onto a completed/fine-tuned Linear OpMode autonomous. Or the autonomous could be re-written as a **state machine** in an Iterative OpMode, with the audio clips played in a **timed sequence**. Not so easy but maybe a good programming project! Learn about Blocks timers at [this FTC Wiki tutorial](https://github.com/FIRST-Tech-Challenge/FtcRobotController/wiki/Timers-in-FTC-Blocks).
|
||||||
|
|
||||||
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user