Update some links, add navigation to top
@ -1,15 +1,17 @@
|
|||||||
|
|
||||||
.
|
.
|
||||||
|
|
||||||
FTC Blocks can play short sounds on the Robot Controller (RC) and Driver Station (DS) phones. Here's a general guide to this fun and useful feature.
|
### Introduction
|
||||||
|
|
||||||
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 Station -- also a 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.
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### Step 1 - Audio Files
|
### Step 1 - Audio Files
|
||||||
|
|
||||||
Find or record your sound files. Blocks can play audio files in the popular **.wav** and **.mp3** formats. Some short samples are posted [here](https://drive.google.com/drive/u/2/folders/1wSuYg5JiL2xmUVx7tfV0vUvIK-ERtv7J).
|
Find or record your sound files. Blocks can play audio files in the popular **.wav** and **.mp3** formats. Some short samples are posted [here](https://github.com/FIRST-Tech-Challenge/WikiSupport/tree/master/FTC-sound-files). Click a file name and then the `Download` button.
|
||||||
|
|
||||||
Most laptop computers can easily make voice recordings.
|
Most laptop computers can easily make voice recordings.
|
||||||
|
|
||||||
@ -17,9 +19,11 @@ Most laptop computers can easily make voice recordings.
|
|||||||
|
|
||||||
In Windows, the Sound Recorder program creates .wma files. Many free websites like [this one](https://audio.online-convert.com/convert-to-mp3) can convert your existing audio file into .wav or .mp3 format.
|
In Windows, the Sound Recorder program creates .wma files. Many free websites like [this one](https://audio.online-convert.com/convert-to-mp3) can convert your existing audio file into .wav or .mp3 format.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Step 2 - My Sounds
|
### Step 2 - My Sounds
|
||||||
|
|
||||||
In the top-level Blocks interface (list of Op Modes), click on "**Sounds**" at the right side of the screen.
|
In the top-level Blocks interface (list of OpModes), click on "**Sounds**" at the right side of the screen.
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0100-top-menu.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0100-top-menu.png|]]<p>
|
||||||
|
|
||||||
@ -27,18 +31,24 @@ This open a new Chrome tab called **My Sounds**, where you can upload and manage
|
|||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0120-My_Sounds-menu.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0120-My_Sounds-menu.png|]]<p>
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Step 3 - SoundPool Menu
|
### Step 3 - SoundPool Menu
|
||||||
|
|
||||||
Leave the My Sounds tab open, and return to the first Chrome tab. Open a Blocks Op Mode (old or new). At the left side, look under Android, and **SoundPool**.
|
Leave the My Sounds tab open, and return to the first Chrome tab. Open a Blocks OpMode (old or new). At the left side, look under Android, and **SoundPool**.
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0130-SoundPool-menu.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0130-SoundPool-menu.png|]]<p>
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Step 4 - Initialize SoundPool
|
### Step 4 - Initialize SoundPool
|
||||||
|
|
||||||
It's best to do this before waitForStart, to save time later.
|
It's best to do this before waitForStart, to save time later.
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0140-initialize-SoundPool.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0140-initialize-SoundPool.png|]]<p>
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Step 5 - Preload Sound
|
### Step 5 - Preload Sound
|
||||||
|
|
||||||
**Optional** to preload the sound file, which theoretically improves response for larger files. This is done with a **Repeat** Loop. Change the '**while**' to '**until**', and attach one of the **preloadSound** Blocks. There's one for the SoundResource class which (in 2019-2020) contains the memorable (!) Skystone sounds, and the other is for your own previously uploaded sound files.
|
**Optional** to preload the sound file, which theoretically improves response for larger files. This is done with a **Repeat** Loop. Change the '**while**' to '**until**', and attach one of the **preloadSound** Blocks. There's one for the SoundResource class which (in 2019-2020) contains the memorable (!) Skystone sounds, and the other is for your own previously uploaded sound files.
|
||||||
@ -47,19 +57,21 @@ It's best to do this before waitForStart, to save time later.
|
|||||||
|
|
||||||
Enter the exact audio filename. The basic preload Block has no pulldown list; check the My Sounds tab to be sure of the filename spelling.
|
Enter the exact audio filename. The basic preload Block has no pulldown list; check the My Sounds tab to be sure of the filename spelling.
|
||||||
|
|
||||||
This purple Block returns 'TRUE' when the preloading task is complete. At that point the 'Repeat Until' loop will end, and the Op Mode will continue.
|
This purple Block returns 'TRUE' when the preloading task is complete. At that point the 'Repeat Until' loop will end, and the OpMode will continue.
|
||||||
|
|
||||||
The loop can remain empty, unless you want to include telemetry re. the preloading status. In any case you might want **telemetry** afterwards to indicate completion.
|
The loop can remain empty, unless you want to include telemetry re. the preloading status. In any case you might want **telemetry** afterwards to indicate completion.
|
||||||
|
|
||||||
For safety and convenience, add a secondary condition to the Repeat Until loop: **OR isStopRequested**. Don't use 'OR NOT opModeIsActive', since you haven't yet pressed START (to make the Op Mode active).
|
For safety and convenience, add a secondary condition to the Repeat Until loop: **OR isStopRequested**. Don't use 'OR NOT opModeIsActive', since you haven't yet pressed START (to make the OpMode active).
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0160-init-telemetry.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0160-init-telemetry.png|]]<p>
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Step 6 - Play Sound
|
### Step 6 - Play Sound
|
||||||
|
|
||||||
Now add the play Block where desired. Again, enter the exact audio filename.
|
Now add the play Block where desired. Again, enter the exact audio filename.
|
||||||
|
|
||||||
This **begins** playback only; the Op Mode will continue immediately afterwards. If you require completion before moving on, determine how much **timed pause** is needed.
|
This **begins** playback only; the OpMode will continue immediately afterwards. If you require completion before moving on, determine how much **timed pause** is needed.
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0170-play-one-sound.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0170-play-one-sound.png|]]<p>
|
||||||
|
|
||||||
@ -77,6 +89,8 @@ Windows Explorer gives a handy estimate of playback duration, rounded to the nea
|
|||||||
|
|
||||||
Right-click on any column heading, and choose "Length" (not "Duration"). This helps when starting to determine the exact amount of timed pause needed by a sound clip.
|
Right-click on any column heading, and choose "Length" (not "Duration"). This helps when starting to determine the exact amount of timed pause needed by a sound clip.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Use in Development
|
### Use in Development
|
||||||
|
|
||||||
Sounds can be a very useful tool for programming and debugging. They can mark the transition from one autonomous action to another, often very hard to see. Different sounds can indicate certain conditions, such as encoder ranges or sensor values, or different stages in the program. Sometimes the robot is executing an unexpected or unknown operation, easily identified with a unique sound.
|
Sounds can be a very useful tool for programming and debugging. They can mark the transition from one autonomous action to another, often very hard to see. Different sounds can indicate certain conditions, such as encoder ranges or sensor values, or different stages in the program. Sometimes the robot is executing an unexpected or unknown operation, easily identified with a unique sound.
|
||||||
@ -85,6 +99,8 @@ Even simple counting values can be indicated with a number of beeps, or with rec
|
|||||||
|
|
||||||
Sounds are most practical in a test environment, without the extreme noise of a tournament.
|
Sounds are most practical in a test environment, without the extreme noise of a tournament.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### SoundPool Options
|
### SoundPool Options
|
||||||
|
|
||||||
Review the **optional** green Blocks to adjust volume, rate and looping. Hover the cursor over each Block for instructions.
|
Review the **optional** green Blocks to adjust volume, rate and looping. Hover the cursor over each Block for instructions.
|
||||||
@ -93,20 +109,24 @@ Review the **optional** green Blocks to adjust volume, rate and looping. Hover t
|
|||||||
|
|
||||||
Make these settings **before** playing the audio file.
|
Make these settings **before** playing the audio file.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Other Notes
|
### Other Notes
|
||||||
|
|
||||||
The sound plays back on **both** RC and DS phones. Make sure the phone **audio** volume is set high, not just the ringtone volume. Note that the REV Control Hub has no speakers.
|
The sound plays back on **both** RC phones and DS devices. Make sure the device **audio** volume is set high, not just the ringtone volume. Note that the REV Control Hub has no speakers.
|
||||||
|
|
||||||
The **.stop** command simply stops a currently playing sound file. It does not permanently disable SoundPool.
|
The **.stop** command simply stops a currently playing sound file. It does not permanently disable SoundPool.
|
||||||
|
|
||||||
<p align="center">[[/images/Playing-Audio-Files/0190-stop.png|]]<p>
|
<p align="center">[[/images/Playing-Audio-Files/0190-stop.png|]]<p>
|
||||||
|
|
||||||
Sound files are stored on the RC phone, 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 Station 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 tutorial on [speech Telemetry](https://github.com/WestsideRobotics/FTC-DS-Speech/wiki).
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
### Longer Playbacks
|
### Longer Playbacks
|
||||||
|
|
||||||
Some users have trouble playing audio files longer than about 6 seconds.
|
Some users have trouble playing audio files longer than about 6 seconds.
|
||||||
@ -125,7 +145,9 @@ 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 Op Mode autonomous. Or the autonomous could be re-written as a **state machine** in an Iterative Op Mode, 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 [here](https://github.com/WestsideRobotics/FTC-Timers/wiki).
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user