home *** CD-ROM | disk | FTP | other *** search
- `Peter Piper 3D, a lip sync demo
- `⌐ 2001, Steve Tiffany, freely distributable
- `Basically, you make an .X object with 7 different mouths occupying
- `the same space. Each mouth is a limb. You make it talk by hiding
- `all the mouth-limbs except one.
- `The mouth-shape data is made using my program Lip Sync Lab,
- `available on my web site at www.stevetiffany.com/vintage.html
-
- `Click mouse to stop.
-
- sync rate 0
- sync on
- gosub SetUp
-
- do
- `pause for a second before speaking, and between recitations...
- sleep 1000
- `get ready to read correct mouth data, play correct sound sample...
- restore peterpiper : soundnum=1
- `then play the sound and display the mouths...
- gosub SayIt
- `now do that for all the other phrases...
- restore picked : soundnum=2 : gosub SayIt
- restore apeckof : soundnum=3 : gosub SayIt
- restore pickledpeppers : soundnum=4 : gosub SayIt
-
- restore apeckof : soundnum=3 : gosub SayIt
- restore pickledpeppers : soundnum=4 : gosub SayIt
- restore did : soundnum=5 : gosub SayIt
- restore peterpiper : soundnum=1 : gosub SayIt
- restore pick : soundnum=6 : gosub SayIt
-
- restore _if : soundnum=7 : gosub SayIt
- restore peterpiper : soundnum=1 : gosub SayIt
- restore picked : soundnum=2 : gosub SayIt
- restore apeckof : soundnum=3 : gosub SayIt
- restore pickledpeppers : soundnum=4 : gosub SayIt
-
- restore howmany : soundnum=8 : gosub SayIt
- restore pickledpeppers : soundnum=4 : gosub SayIt
- restore did : soundnum=5 : gosub SayIt
- restore peterpiper : soundnum=1 : gosub SayIt
- restore pickQ : soundnum=9 : gosub SayIt
- loop
-
- `play the sound and display the mouth shapes...
- SayIt:
- play sound soundnum
- `format: number of mouths, first mouth shape number, how long to display,
- `next mouth shape, how long to display it, etc....
- read nummouths
- for j=1 to nummouths
- `note starting time...
- oldtimer=timer()
- read mouthshape
- read waittime
- `hide all mouths...
- for k=2 to 8
- hide limb 1,k
- next k
- `then display only the mouth that corresponds to mouthshape
- `(the mouths in this .x object are in the wrong order, otherwise you
- ` could just do Show Limb 1,mouthshape)...
- `Use limbcount.dba to determine which limb corresponds to which mouthshape...
- if mouthshape=1 : show limb 1,5 : endif
- if mouthshape=2 : show limb 1,8 : endif
- if mouthshape=3 : show limb 1,7 : endif
- if mouthshape=4 : show limb 1,4 : endif
- if mouthshape=5 : show limb 1,3 : endif
- if mouthshape=6 : show limb 1,2 : endif
- if mouthshape=7 : show limb 1,6 : endif
- sync
- `display the mouth for the time specified...
- while timer() < oldtimer+waittime
- `while you're waiting, see if they clicked the mouse...
- if mouseclick()=1 then gosub CleanUp
- sync
- endwhile
- next j
- `wait here if the sound is still playing when you run out of mouths...
- while sound playing(soundnum)
- if mouseclick()=1 then gosub CleanUp
- sync
- endwhile
- return
-
- peterpiper:
- data 10,1,48,6,64,2,32,3,32,4,96,1,64,3,128,1,48,3,48,4,64
- picked:
- data 3,1,48,3,80,2,128
- apeckof:
- data 6,3,176,1,48,3,144,2,128,3,80,7,144
- pickledpeppers:
- data 11,1,48,3,80,2,32,3,48,2,64,1,48,3,80,1,64,3,64,4,96,2,240
- did:
- data 3,2,32,3,64,2,80
- pick:
- data 4,1,64,3,144,2,160,1,80
- _if:
- data 2,3,96,7,256
- howmany:
- data 7,2,80,5,64,4,48,1,32,3,32,2,96,6,160
- pickQ:
- data 4,1,64,3,208,2,160,1,208
-
- SetUp:
- `load sounds 1-9...
- restore soundnames
- for j=1 to 9
- read soundname$
- a$="wav\"+soundname$+".wav"
- load sound a$,j
- next j
-
- `load and position object...
- load object "bmp\mouth.x",1
- `use move.dba to position your .X object and get these numbers...
- position object 1,5.5,-0.9,-14.9
- rotate object 1,4,2,0
-
- hide mouse
- randomize timer()
- rem hide all mouths...
- for j=2 to 8
- hide limb 1,j
- next j
- `then show the closed mouth
- show limb 1,5
- return
- soundnames:
- data "peterpiper","picked","apeckof","pickledpeppers","did"
- data "pick","_if","howmany","pickQ"
-
- CleanUp:
- cls 0
- wait 10
- delete object 1
- For j=1 to 9
- delete sound j
- next j
- end
- return
-