PDF Print E-mail

 

Lessons from BOB : PART THREE

 

Making it Talk

 

 

Let’s put some sound on our robot.

 

There are many sound files preloaded in the FICE SD card.  Please refer to ‘FIDE Language Reference’ for a detailed explanation.

 

To play a certain sound, we make use of the command OS.Wave.Play.  OS.Wave.Play takes 3 arguments. The first argument is Cluster, the second argument is StartSector and the third is EndSector. To understand how to use the OS.Wave.Play, we’ll go through an example.

 

To play the sound “get”, we look up in the ‘FIDE Language Reference’ and find that it is the 95th word in the list of a Hundred Words. We also know that the Hundred Words are located in Cluster 11.

 

 No.VOCAB
File/s 
BlockStart   
BlockEnd    
Block Length 
Last Pos. in Block
 95 get W0095.wav2437 2454 18 0
                                                               

Cluster 8 = 2 songs

Cluster 9 = Numbers

Cluster 10 = Alphabets

Cluster 11 = Hundred words (refer to APPENDIX A in the Language Ref)

 

So to play the sound “get”, we use OS.Wave.Play(11, 2437, 2454).  Let’s try it.


Now let’s find the word “down” and play it.

No.VOCAB
File/s 
BlockStart   
BlockEnd    
Block Length 
Last Pos. in Block
92    
down         W0092.wav      
2361               2395 35                  
0                              

 CODE:

 

OS.Wave.Play(11, 2361, 2395)

 

 

To play both words, “get down”, we have to put a delay, so that there is time for the processor to finish saying the first word before starting on the second word.  Your code should look something like the one below.

 

 CODE:

 

OS.Wave.Play(11, 2437, 2454) 'say 'get'

Delay(500)

OS.Wave.Play(11, 2361, 2395) 'say 'down'

Delay(500)

 


Having a delay is a necessity but if we need to do other stuff, like drawing a mouth on the GLCD, the delay will not do.  Instead we can check if the processor has finished saying the word.  Try the code below.

 

 CODE:

 

OS.Wave.Play(11, 2437, 2454) 'say 'get'

Do

Loop Until OS.Wave.State() = 0

OS.Wave.Play(11, 2361, 2395) 'say 'down'

Do

Loop Until OS.Wave.State() = 0

 

 

Notice that the next word is said immediately after the first word has been said.

 

Now it’s time to add the talking GLCD program with the sound program. 

No.VOCAB   
File/s 
BlockStart 
BlockEnd     
Block Length 
Last Pos. in Block
 9     
 it W0009.wav       
 241 257 17 0
 13  on            W0013.wav 329 350 22  0

 

CODE:

 

OS.Wave.Play(11, 2437, 2454) 'say get

Do

Loop Until OS.Wave.State() = 0

POS = RND(3) + 3

'DRAW MOUTH

DRAW_MOUTH(32, 30, POS)

 

OS.Wave.Play(11, 2361, 2395) 'say down

Do

Loop Until OS.Wave.State() = 0

POS = RND(3) + 3

'DRAW MOUTH

DRAW_MOUTH(32, 30, POS)

 

OS.Wave.Play(11, 329, 350) 'say on

Do

Loop Until OS.Wave.State() = 0

POS = RND(3) + 3

'DRAW MOUTH

DRAW_MOUTH(32, 30, POS)

 

OS.Wave.Play(11, 241, 257) 'say it

Do

Loop Until OS.Wave.State() = 0

POS = RND(3) + 3

'DRAW MOUTH

DRAW_MOUTH(32, 30, POS)

 


Don’t forget that you need to include the initializing of the GLCD and also include DRAW_LIB into your project.

 

CODE:

 

 'Module1


Dim POS As Integer

 

'LESSON 2

Public Sub Main()

       OS.GLCD.Init()

       OS.GLCD.Fill(255)

 

       'DRAW RIGHT EYE

       DRAW_EYE(25, 70, True)

       'DRAW LEFT EYE

       DRAW_EYE(75, 70, True)

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, 1)

 

       Delay(1000) 'DELAY FOR 1 SEC

       'CLOSE RIGHT EYE

       DRAW_EYE(25, 70, False)

 

       Delay(500) 'WAIT FOR A WHILE

 

       'DRAW RIGHT EYE

       DRAW_EYE(25, 70, True)

 

       Delay(500)

 

       OS.Wave.Play(11, 2437, 2454) 'say get

       Do

       Loop Until OS.Wave.State() = 0

       POS = RND(3) + 3

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, POS)

      

       OS.Wave.Play(11, 2361, 2395) 'say down

       Do

       Loop Until OS.Wave.State() = 0

       POS = RND(3) + 3

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, POS)

      

       OS.Wave.Play(11, 329, 350) 'say on

       Do

       Loop Until OS.Wave.State() = 0

       POS = RND(3) + 3

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, POS)

      

       OS.Wave.Play(11, 241, 257) 'say it

       Do

       Loop Until OS.Wave.State() = 0

       POS = RND(3) + 3

       'DRAW MOUTH

       DRAW_MOUTH(32, 30, POS)

 

 

       'DRAW MOUTH - initial position

       DRAW_MOUTH(32, 30, 1)

End Sub

 


 

 


download_sourceCode.png

 

Lost? Try backtracking to Part One and Part Two.

 

 

 

 

 
Previous Next
Two New Tutorials
Learn how to control a Servo Motor with the FIDE, as well as adding a wireless peer-to-peer communication link using the EBlue Bluetooth Module.
Hoorah! We've Updated!
3 Cheers to a new tutorial, a FIDE patch, and a Language Reference Update!
New Sensor and Documentation Updates

 

We now carry the distance measuring sensor, SHARP GP2D12, WITH the compatible 3pin connector.

In other updates, we have uploaded the technical paper for our GLCD+RTC Combo complete with example configurations to our FlamingICE Boards. 

Our Hardware Reference now stands at version 1.5 with slight changes to the pin-outs on the FI28 Board. 

 

Christmas Updates

Download the latest FIDE v2.1 and get all the updated documentation that comes along with it!

Check out the new goodies that we have over at our updated Products Page!

Resource Page

Now that FIDE 2.0 is up, we published the Resource Page with 2 major tutorials to boot.

Start clicking and head over to check out those tutorials!

FIDE v2.0 RELEASED!

AIS Cube is proud to release the latest and most complete installment to date, FIDE v2.0. Delivering faster feature packed goodness, whats not to love?

Head over to the downloads tab and grab your copy!

FIDE v1.4.2 PATCH

IMPORTANT: Responding to a bug report, the FIDE v1.4.2 PATCH is a patch for a major bug fix in the FIDE SD Tool. Please ensure that you have FIDE v1.4.2 installed before proceeding with the Patch.

Patch is available over on the Downloads Tab.

FIDE v1.4 Released!
More features with the latest release of FIDE at version 1.4. Extended syntax highlighting range, greater support for FIDE system language instructions...
FIDE v1.3 Released!

FIDE v1.3 is now available for download over at the downloads tab. Featuring bug fixes and other features such as an expanded syntax highlighting coverage, it is highly recommended that you upgrade to the newest version.

AVRIL LE BOB

We have a new project named AVRIL LE BOB up over at the projects page (with videos!!). Check it out today!


Copyright © 2007-2008. AIS Cube. All Rights Reserved.
All trade and/or services marks mentioned are the property of their respective owners.
Joomla! is Free Software released under the GNU/GPL License.