So I set up my talking people with dark voices, everything works great in the sample program with my modles, but when I transfer the code to my game project the mouths do not move, the sound plays but no mouth movment at all. I belive its the return from this
if spacekey()=1 then currentsoundfile$="darkvoices_05.wav" :gosub _lipsync_playspeech
gosub _lipsync_control
Well it does not gosub _lipsync_control if it did my mouths would move, I set the code up proerly, exacly the same, no diffrence at all. So My question is can scaleing the heads smaller effect the play animations of the heads? Or could it be that trully this progam only works with one modle at a time? Any how here is the code im using taken from my huge project.
rem data for lipsync code
type lipsynctype
s as DWORD
e as DWORD
t as DWORD
s$ as string
endtype
dim timeline(25000) as lipsynctype
ph_a=1 : ph_c=2 : ph_e=3 : ph_f=4 : ph_l=5
ph_m=6 : ph_o=7 : ph_r=8 : ph_u=9 : ph_w=10
ph_rest=11
rem Load the head model
headobjid=5000 : gosub _lipsync_head
rem Load your game model
load object "lipsync\body2.x",2
yrotate object 2,180
position object 2,0,240,10
load image "lipsync\Drunk_1_D2.dds",500
texture object 2,500
rem Attach head to game model
rotate object headobjid,0,0,-90
glue object to limb headobjid,2,37,2
position object headobjid,10,0,5
rem Main loop
do
rem a tool to check limbs, hit F11 to see limbs
for w=1 to 100
perform checklist for object limbs headobjid
if limb exist (headobjid,w)=1
set cursor ScrW*0.75,w*10
if keystate(87)=1 then print "limb ",w,".....",checklist string$(w)
endif
next w
`
rem Control blinking
if blink=0
offset limb headobjid,8,0,200,ffa#/5.0
offset limb headobjid,8,0,ffa#/5.0,ffa#*-1
offset limb headobjid,10,0,200,ffa#/5.0
offset limb headobjid,10,0,ffa#/5.0,ffa#*-1
if rnd(100)=1 then blink=1
else
fff#=fff#+64 : ffa#=2.0-(cos(fff#)*2.0)
if fff#>345 then fff#=0 : blink=0 : ffa#=0.0
endif
if blink=1
offset limb headobjid,8,0,200,ffa#/5.0
offset limb headobjid,8,-4,ffa#/5.0,ffa#*-1
offset limb headobjid,10,0,200,ffa#/5.0
offset limb headobjid,10,-4,ffa#/5.0,ffa#*-1
endif
rem Move game body around
if playing=0
rem game object walks in circle
else
rem game object stops and faces camera
endif
set object speed 2,60
loop object 2,0,200
control camera using arrowkeys 0,6,1
rem Move light to camera position
set point light 0,camera position x(),camera position y(),camera position z()
set light range 0,5000
`
rem Control mouth in head
if spacekey()=1 then currentsoundfile$="darkvoices_05.wav" : gosub _lipsync_playspeech
gosub _lipsync_control
`
rem Prompt
if keystate(88)=1
screenshot = 0
repeat
INC screenshot
until FILE EXIST("ScreenShots/Screenshot Number - " + STR$(screenshot) + ".jpg") <> 1
img = FIND FREE IMAGE()
GET IMAGE img, 0, 0, SCREEN WIDTH(), SCREEN HEIGHT(), 1
SAVE IMAGE "ScreenShots/Screenshot Number - " + STR$(screenshot) + ".jpg", img
DELETE IMAGE img
endif
`
rem Update screen
sync
`
rem End loop
loop
rem
rem DARKVOICES LIPSYNC SUBROUTINES
rem
rem _lipsync_head - load the head model
rem _lipsync_playspeech - load and play speech
rem _lipsync_timeline_process - load LIPSYNC data into array
rem _lipsync_control - control mouth during speech
_lipsync_head:
load object "lipsync\head2.x",headobjid
load image "lipsync\Drunk_1_D2.dds",501
texture object headobjid,501
yrotate object headobjid,180
fix object pivot headobjid
return
_lipsync_playspeech:
rem load WAV sound and LIPSYNC data
if playing=0
if oldcurrentsoundfile$<>currentsoundfile$
oldcurrentsoundfile$=currentsoundfile$
if sound exist(1)=1 then delete sound 1
load sound currentsoundfile$,1
lipsyncfile$=left$(currentsoundfile$,len(currentsoundfile$)-4)+".lipsync"
gosub _lipsync_timeline_process
endif
play sound 1
time=timer()
playing=1
endif
return
_lipsync_timeline_process:
dim lipsync$(25000)
for t=0 to 24999
lipsync$(t)=""
next t
timelineptr=0
load array lipsyncfile$,lipsync$()
for l=1 to 24999
`
rem cut up phm
cuti=0
dim cut$(5)
cut$(0)=""
cut$(1)=""
cut$(2)=""
cut$(3)=""
cut$(4)=""
cut$(5)=""
cutme$=lipsync$(l)
for n=1 to len(cutme$)+1
if len(cutme$)>=1 and cuti<=5
if mid$(cutme$,n)=" " or n=len(cutme$)
if n=len(cutme$)
cut$(cuti)=lower$(left$(cutme$,n))
cutme$=right$(cutme$,len(cutme$)-(len(cut$(cuti))))
else
cut$(cuti)=lower$(left$(cutme$,n-1))
cutme$=right$(cutme$,len(cutme$)-(len(cut$(cuti))+1))
endif
inc cuti
n=0
endif
endif
next n
`
rem approximations to 10 poses (ideally 39)
if cut$(0)="phn"
st=val(cut$(1))
en=val(cut$(2))
if cut$(4)="m" then ty=ph_m
if cut$(4)="ae" then ty=ph_a
if cut$(4)="n" then ty=ph_c
if cut$(4)="ay" then ty=ph_a
if cut$(4)="x" then ty=ph_rest
if cut$(4)="iy" then ty=ph_a
if cut$(4)="ih" then ty=ph_a
if cut$(4)="eh" then ty=ph_e
if cut$(4)="ah" then ty=ph_a
if cut$(4)="uw" then ty=ph_w
if cut$(4)="uh" then ty=ph_w
if cut$(4)="aa" then ty=ph_a
if cut$(4)="ao" then ty=ph_o
if cut$(4)="ey" then ty=ph_a
if cut$(4)="oy" then ty=ph_o
if cut$(4)="aw" then ty=ph_o
if cut$(4)="ow" then ty=ph_o
if cut$(4)="l" then ty=ph_l
if cut$(4)="r" then ty=ph_r
if cut$(4)="y" then ty=ph_u
if cut$(4)="w" then ty=ph_w
if cut$(4)="er" then ty=ph_u
if cut$(4)="ng" then ty=ph_c
if cut$(4)="ch" then ty=ph_u
if cut$(4)="j" then ty=ph_r
if cut$(4)="dh" then ty=ph_l
if cut$(4)="b" then ty=ph_m
if cut$(4)="d" then ty=ph_l
if cut$(4)="g" then ty=ph_r
if cut$(4)="p" then ty=ph_m
if cut$(4)="t" then ty=ph_r
if cut$(4)="k" then ty=ph_c
if cut$(4)="z" then ty=ph_c
if cut$(4)="zh" then ty=ph_c
if cut$(4)="v" then ty=ph_f
if cut$(4)="f" then ty=ph_f
if cut$(4)="th" then ty=ph_l
if cut$(4)="s" then ty=ph_r
if cut$(4)="sh" then ty=ph_r
if cut$(4)="h" then ty=ph_r
inc timelineptr
timeline(timelineptr).s=st
timeline(timelineptr).e=en
timeline(timelineptr).t=ty
timeline(timelineptr).s$=cut$(4)
endif
`
next l
timelinemax=timelineptr
return
_lipsync_control:
`
rem get mouth pose
pose=0
if playing=1
current as DWORD
current=(timer()-time)+150
for t=1 to timelinemax
if current>=timeline(t).s and current<=timeline(t).e
pose=timeline(t).t
if pose=ph_rest then pose=0
if pose<>lastpose
posetravelspeed=timeline(t).e-current
endif
lastpose=pose
endif
next t
if sound playing(1)=0 then playing=0
endif
`
rem set frame of mouth in head model to match pose
tpose=pose
if tpose=0 then fr=1-1
if tpose=1 then fr=2-1
if tpose=2 then fr=5-1
if tpose=3 then fr=3-1
if tpose=4 then fr=4-1
if tpose=5 then fr=6-1
if tpose=6 then fr=7-1
if tpose=7 then fr=8-1
if tpose=8 then fr=11-1
if tpose=9 then fr=9-1
if tpose=10 then fr=10-1
screenrate#=screen fps()
if fr<>lfr
lfr=fr
if posetravelspeed>0
screenrate#=1000.0/screenrate#
posetravelspeed=posetravelspeed-screenrate#
percspeed#=(posetravelspeed+0.0)/screenrate#
if percspeed#<1.0 then percspeed#=1.0
posetravelspeed=0
endif
set object interpolation headobjid,100.0/percspeed#
set object frame headobjid,fr*120
endif
`
return
my signature keeps being erased by a mod So this is my new signature.