/* Speaker Client - DMS - Apr 98 - by Sylvain HUET */ var bitmapfile="Dms/Sound/Speaker/recon.bmp";; var bitmapfile2="Dms/Sound/Speaker/recoff.bmp";; var bitmapfile3="Dms/Sound/Speaker/playon.bmp";; var bitmapfile4="Dms/Sound/Speaker/playoff.bmp";; var bitmapfile5="Dms/Sound/Speaker/playmute.bmp";; defcom Cregister=register I;; defcom Csilent=silent;; defcom Csound=sound S S;; fun getUdp(i,j)= if i>=j then nil else let _setUDP _envchannel _channel i "" -> c in if c==nil then getUdp i+1 j else [c i];; typeof clis=[S r1];; typeof udp=Chn;; typeof bmpon=ObjBitmap;; typeof bmpoff=ObjBitmap;; typeof bmppon=ObjBitmap;; typeof bmppoff=ObjBitmap;; typeof bmppmute=ObjBitmap;; typeof win=ObjWin;; typeof win2=ObjWin;; typeof info=ObjText;; typeof udpserver=S;; typeof udpport=I;; var silent=1;; fun mystrcmp(a,b)=!strcmp a b;; fun broad(a,z)= _sendUDP a z;; fun _paintE(a,b)= _BLTbitmap win if recording then bmpon else bmpoff 0 0; _BLTbitmap win2 if silent then bmppmute else if playing then bmppon else bmppoff 0 0; if playing then nil else _SETtext info ""; 0;; fun speak(s)= if udpserver==nil then apply_on_list clis @broad Csound [DMSlogin s] else _sendUDP udpserver Csound [DMSlogin s];; fun _clickE(a,m,x,y,button)= if recording then nil else if udpserver!=nil && !strcmp udpserver "" then nil else (startrecsnd; _paintE nil nil);; fun _clickE2(a,m,x,y,button)= set silent= if silent then (_DMSsend this Cregister [udpport]; set clis=nil; 0) else (_DMSsend this Csilent []; set clis=nil; 1); _paintE nil nil;; fun _unclickE(a,m,x,y,button)= /* if button==2 then nil else*/ stoprecsnd; _paintE nil nil;; fun before()=_killchannel udp;; fun _end(b)= _DMSdelete this;; fun _resize(x,s)= let x->[_ x y w h] in _SIZEwindow win w h x y; 0;; fun _resize2(x,s)= let x->[_ x y w h] in _SIZEwindow win2 w h x y; 0;; fun _resizeT(x,s)= let x->[_ x y w h] in _SIZEtext info w h x y; 0;; fun _moveE(a,b,x,y,c)= _SETwinCursor win HandCursor;; fun IniDMI(param)= set udpserver= if param!=nil && strcmp param "" then strcat strcat _channelIP DMSserver ":" param else param; _DMSregisterDMI this nil @before; let getUdp 3000 4000->[c i] in (set udpport=i; set udp=c); set bmpon=_LDbitmap _channel _checkpack bitmapfile; set bmpoff=_LDbitmap _channel _checkpack bitmapfile2; set bmppon=_LDbitmap _channel _checkpack bitmapfile3; set bmppoff=_LDbitmap _channel _checkpack bitmapfile4; set bmppmute=_LDbitmap _channel _checkpack bitmapfile5; if param!=nil && !strcmp param "" then nil else let _DMSgetZone this "ButtonRec" @_end @_resize @_end ->[wn x y w h] in if wn==nil then nil else (set win=_CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "speaker"; _CBwinPaint win @_paintE 0; _paintE nil nil; _CBcursorMove win @_moveE 0; _CBwinClick win @_clickE 0; _CBwinUnclick win @_unclickE 0); let _DMSgetZone this "ButtonPlay" @_end @_resize2 @_end ->[wn x y w h] in if wn==nil then nil else (set win2=_CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "speaker"; _CBwinPaint win2 @_paintE 0; _paintE nil nil; _CBcursorMove win2 @_moveE 0; _CBwinClick win2 @_clickE2 0); let _DMSgetZone this "Info" nil @_resizeT @_end ->[win x y w h] in if win==nil then nil else set info=_CRtext _channel win x y w h ET_ALIGN_CENTER ""; iniAudio; set cbrec=@speak; 0;; fun __enter(udp)= if silent then nil else set clis=udp::clis;; fun __leave(udp)= let search_in_list clis @mystrcmp udp -> c in if c==nil then nil else set clis=remove_from_list clis c;; fun __sound (name,audio)= if silent then nil else (GetAudio name audio;_SETtext info name);;