home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / programming / amos / lipsynclab / buster.amos / buster.amosSourceCode
AMOS Source Code  |  1998-04-23  |  4KB  |  143 lines

  1. 'Buster Speaks, ï¿½1998 Steve Tiffany  
  2. 'an example of using LipSyncLab data with HAM screens...   
  3. 'The data generated by LSL goes into the procedure AD[], where it gets copied
  4. 'as needed to files in ram: that hold which samples to play and all necessary  
  5. 'mouth data... 
  6.  
  7. Global SAMDIR$,CURRDIR$,PICDIR$
  8.  
  9. 'Important!  Change next line to true location of LipSyncLab directory...      
  10. CURRDIR$="work:LipSyncLab/"
  11. 'CURRDIR$=Dir$ : Rem : Change to this just before compiling. 
  12.  
  13. Proc SETUP
  14.  
  15. Do 
  16.    Proc WRITESCENE
  17.    Proc PERFORMSCENE
  18. Loop 
  19.  
  20. Procedure SETUP
  21.    SAMDIR$=CURRDIR$+"Samples/" : PICDIR$=CURRDIR$+"Pictures/"
  22.  
  23.    Screen Open 0,320,200,2,Lowres : Cls 0 : 
  24.    Auto View Off 
  25.   'load pictures to screens 1-7...   
  26.    For J=1 To 7
  27.       Screen Open J,320,200,4096,Lowres
  28.       Hide 
  29.       J$=PICDIR$+"Buster"+Str$(J)-" "
  30.       Load Iff J$
  31.    Next J
  32.    Screen To Front 1
  33.    Auto View On 
  34.  
  35.    'longest possible sentence is 8 samples, so open 8 banks...
  36.    For J=10 To 17
  37.       Reserve As Chip Work J,8032 : Rem : temporary banks to hold samples  
  38.    Next J
  39. End Proc
  40.  
  41. Procedure WRITESCENE
  42.    'write files in ram: for the words he'll say...  
  43.  
  44.    Open Out 1,"ram:SceneNums.asc" : Open Out 2,"ram:SceneWords.asc"
  45.    'Gotta have two separate files because first you load all samples into 
  46.    'memory banks, then you play them one by one and display the mouths. 
  47.    'If it's all in one file, there's all this mouth data in between the 
  48.    'sample names, so it can't tell which samples to pre-load.   
  49.  
  50.       AD["think"] : AD["of"] : AD["soup"] : AD["."]
  51.       AD["soup"] : AD["like"] : AD["Iwould"] : AD["make"] : AD["you"] : AD["."]
  52.       AD["you"] : AD["forget"] : AD["me"] : AD["but"] : AD["Iwould"] : 
  53.           AD["think"] : AD["of"] : AD["you"] : AD["."]
  54.       AD["Iwould"] : AD["like"] : AD["you"] : AD["."]
  55.       AD["Iwould"] : AD["like"] : AD["you"] : AD["to"] : 
  56.          AD["make"] : AD["me"] : AD["soup"] : AD["."]
  57.       AD["Iwould"] : AD["like"] : AD["you"] : AD["to"] : AD["forget"] : AD["."]
  58.       AD["Iwould"] : AD["forget"] : AD["you"] : AD["but"] : 
  59.          AD["think"] : AD["of"] : AD["soup"] : AD["."] : AD["END"]
  60.    Close 1 : Close 2
  61. End Proc
  62.  
  63. Procedure PERFORMSCENE
  64. 'speak the sentences by reading the files...   
  65.  
  66.    Open In 1,"ram:SceneNums.asc" : Open In 2,"ram:SceneWords.asc"
  67.    Do 
  68.       CURRBANK=9
  69.       Gosub BANKLOAD : Rem : load all samples in this sentence  
  70.       If WORD$="END" Then Exit 
  71.       Gosub PERFORMSENT
  72.    Loop 
  73.    Close 1 : Close 2
  74.    Pop Proc
  75.  
  76. BANKLOAD:
  77.    Do 
  78.       Input #2,WORD$ : 
  79.       If WORD$="END"
  80.          Return : Rem : it's over  
  81.       Else If WORD$="SpeakSent"
  82.          Return : Rem : speak the sentence 
  83.       Else 
  84.          Inc CURRBANK
  85.          SAM$=SAMDIR$+WORD$
  86.          Bload SAM$,Start(CURRBANK) : Rem : load sample into temporary bank    
  87.       End If 
  88.    Loop 
  89. Return 
  90.  
  91. PERFORMSENT:
  92.    For K=10 To CURRBANK
  93.       Input #1,SAMLEN : Input #1,NUMMOUTHS
  94.       Sam Raw 3,Start(K),SAMLEN,13982
  95.       For J=1 To NUMMOUTHS
  96.          XWAITRESS=Timer
  97.          Input #1,MOUTHNUM : Screen To Front MOUTHNUM
  98.          Input #1,MOUTHWAIT : 
  99.          While Timer<XWAITRESS+MOUTHWAIT : Rem : check for clicks while waiting 
  100.             If Mouse Click=1
  101.                Close 1 : Close 2
  102.                Kill "ram:SceneNums.asc"
  103.                Kill "ram:SceneWords.asc" : Edit 
  104.             End If 
  105.          Wend 
  106.       Next J
  107.    Next K
  108.    Screen To Front 1
  109.    Wait 30
  110. Return 
  111. End Proc
  112.  
  113. Procedure AD[WORD$]
  114.   'adds the word and its relevant data to the file in ram: ...   
  115.    If WORD$="."
  116.       Print #2,"SpeakSent"
  117.    Else If WORD$="END"
  118.       Print #2,"END"
  119.    Else 
  120.       Print #2,WORD$
  121.       WORD$="_"+Upper$(WORD$)-" "
  122.       Restore WORD$ : 
  123.       Read SAMLENGTH : Print #1,SAMLENGTH
  124.       Read NUMMOUTHS : Print #1,NUMMOUTHS
  125.       For J=1 To NUMMOUTHS
  126.          Read MOUTHNUM : Print #1,MOUTHNUM : 
  127.          Read MOUTHWAIT : Print #1,MOUTHWAIT
  128.       Next J
  129.    End If 
  130.    Pop Proc
  131.  
  132. _BUT: Data 2346,3,1,2,3,4,2,5
  133. _FORGET: Data 8022,6,7,3,3,4,4,6,2,4,3,10,2,7
  134. _IWOULD: Data 6442,4,3,5,2,4,4,10,2,9
  135. _LIKE: Data 5616,3,2,8,3,8,2,8
  136. _MAKE: Data 4004,3,1,3,3,6,2,8
  137. _ME: Data 4236,2,1,5,6,14
  138. _OF: Data 2730,2,3,3,7,9
  139. _SOUP: Data 7756,3,2,12,4,14,1,8
  140. _THINK: Data 4320,3,2,2,3,6,2,11
  141. _TO: Data 2686,3,2,3,3,4,2,4
  142. _YOU: Data 4766,2,2,4,4,16
  143. End Proc