home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / LipSync / PeterPiper3D.dba < prev    next >
Encoding:
Text File  |  2001-01-23  |  4.2 KB  |  143 lines

  1. `Peter Piper 3D, a lip sync demo
  2. `⌐ 2001, Steve Tiffany, freely distributable
  3. `Basically, you make an .X object with 7 different mouths occupying
  4. `the same space.  Each mouth is a limb.  You make it talk by hiding
  5. `all the mouth-limbs except one.
  6. `The mouth-shape data is made using my program Lip Sync Lab,
  7. `available on my web site at www.stevetiffany.com/vintage.html
  8.  
  9. `Click mouse to stop.
  10.  
  11. sync rate 0
  12. sync on
  13. gosub SetUp
  14.  
  15. do
  16.    `pause for a second before speaking, and between recitations...
  17.    sleep 1000
  18.    `get ready to read correct mouth data, play correct sound sample...
  19.    restore peterpiper : soundnum=1
  20.    `then play the sound and display the mouths...
  21.    gosub SayIt
  22.    `now do that for all the other phrases...
  23.    restore picked : soundnum=2 : gosub SayIt
  24.    restore apeckof : soundnum=3 : gosub SayIt
  25.    restore pickledpeppers : soundnum=4 : gosub SayIt
  26.  
  27.    restore apeckof : soundnum=3 : gosub SayIt
  28.    restore pickledpeppers : soundnum=4 : gosub SayIt
  29.    restore did : soundnum=5 : gosub SayIt
  30.    restore peterpiper : soundnum=1 : gosub SayIt
  31.    restore pick : soundnum=6 : gosub SayIt
  32.  
  33.    restore _if : soundnum=7 : gosub SayIt
  34.    restore peterpiper : soundnum=1 : gosub SayIt
  35.    restore picked : soundnum=2 : gosub SayIt
  36.    restore apeckof : soundnum=3 : gosub SayIt
  37.    restore pickledpeppers : soundnum=4 : gosub SayIt
  38.  
  39.    restore howmany : soundnum=8 : gosub SayIt
  40.    restore pickledpeppers : soundnum=4 : gosub SayIt
  41.    restore did : soundnum=5 : gosub SayIt
  42.    restore peterpiper : soundnum=1 : gosub SayIt
  43.    restore pickQ : soundnum=9 : gosub SayIt
  44. loop
  45.  
  46. `play the sound and display the mouth shapes...
  47. SayIt:
  48.    play sound soundnum
  49.    `format: number of mouths, first mouth shape number, how long to display,
  50.    `next mouth shape, how long to display it, etc....
  51.    read nummouths
  52.    for j=1 to nummouths
  53.       `note starting time...
  54.       oldtimer=timer()
  55.       read mouthshape
  56.       read waittime
  57.       `hide all mouths...
  58.       for k=2 to 8
  59.          hide limb 1,k
  60.       next k
  61.       `then display only the mouth that corresponds to mouthshape
  62.       `(the mouths in this .x object are in the wrong order, otherwise you
  63.       ` could just do Show Limb 1,mouthshape)...
  64.       `Use limbcount.dba to determine which limb corresponds to which mouthshape...
  65.       if mouthshape=1 : show limb 1,5 : endif
  66.       if mouthshape=2 : show limb 1,8 : endif
  67.       if mouthshape=3 : show limb 1,7 : endif
  68.       if mouthshape=4 : show limb 1,4 : endif
  69.       if mouthshape=5 : show limb 1,3 : endif
  70.       if mouthshape=6 : show limb 1,2 : endif
  71.       if mouthshape=7 : show limb 1,6 : endif
  72.       sync
  73.       `display the mouth for the time specified...
  74.       while timer() < oldtimer+waittime
  75.          `while you're waiting, see if they clicked the mouse...
  76.          if mouseclick()=1 then gosub CleanUp
  77.          sync
  78.       endwhile
  79.    next j
  80.    `wait here if the sound is still playing when you run out of mouths...
  81.    while sound playing(soundnum)
  82.       if mouseclick()=1 then gosub CleanUp
  83.       sync
  84.    endwhile
  85. return
  86.  
  87. peterpiper:
  88. data 10,1,48,6,64,2,32,3,32,4,96,1,64,3,128,1,48,3,48,4,64
  89. picked:
  90. data 3,1,48,3,80,2,128
  91. apeckof:
  92. data 6,3,176,1,48,3,144,2,128,3,80,7,144
  93. pickledpeppers:
  94. data 11,1,48,3,80,2,32,3,48,2,64,1,48,3,80,1,64,3,64,4,96,2,240
  95. did:
  96. data 3,2,32,3,64,2,80
  97. pick:
  98. data 4,1,64,3,144,2,160,1,80
  99. _if:
  100. data 2,3,96,7,256
  101. howmany:
  102. data 7,2,80,5,64,4,48,1,32,3,32,2,96,6,160
  103. pickQ:
  104. data 4,1,64,3,208,2,160,1,208
  105.  
  106. SetUp:
  107.    `load sounds 1-9...
  108.    restore soundnames
  109.    for j=1 to 9
  110.       read soundname$
  111.       a$="wav\"+soundname$+".wav"
  112.       load sound a$,j
  113.    next j
  114.  
  115.    `load and position object...
  116.    load object "bmp\mouth.x",1
  117.    `use move.dba to position your .X object and get these numbers...
  118.    position object 1,5.5,-0.9,-14.9
  119.    rotate object 1,4,2,0
  120.  
  121.    hide mouse
  122.    randomize timer()
  123.    rem hide all mouths...
  124.    for j=2 to 8
  125.       hide limb 1,j
  126.    next j
  127.    `then show the closed mouth
  128.    show limb 1,5
  129.    return
  130. soundnames:
  131. data "peterpiper","picked","apeckof","pickledpeppers","did"
  132. data "pick","_if","howmany","pickQ"
  133.  
  134. CleanUp:
  135.    cls 0
  136.    wait 10
  137.    delete object 1
  138.    For j=1 to 9
  139.       delete sound j
  140.    next j
  141.    end
  142.    return
  143.