/* Speaker Client - DMS - Apr 98 - by Sylvain HUET */ /* longspeaker ver 1.0 - part client - 01/2004 */ /* by iri : info@irizone.net */ 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 bmpinfo=ObjBitmap;; /* bitmap background zone info */ typeof winfo = ObjWin;; /* window info */ typeof udpserver=S;; typeof udpport=I;; var silent=1;; typeof longspeech = I;; /* boolean keep clicDown for speak or not */ typeof sizefont = I;; /* font size */ typeof fontcolor = I;; /* font color */ /* paths des bitmaps */ typeof recon = S;; typeof recoff = S;; typeof playon = S;; typeof playoff = S;; typeof playmute = S;; typeof bgbmp = S;; typeof jpgBmp = I;; /* background window "winfo" jpeg -> 1, bmp -> 0 */ typeof cptBmp = I;; /* compteur dwl bitmap */ fun mystrcmp(a,b)=!strcmp a b;; fun broad(a,z)= _sendUDP a z;; /* création du bitmap background winfo - background vierge */ fun bgLogin(b)= if b then set bmpinfo = _LDjpeg _channel _checkpack bgbmp else set bmpinfo = _LDbitmap _channel _checkpack bgbmp; 0;; 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 ( /* restitue le background "winfo" */ bgLogin jpgBmp; _BLTbitmap winfo bmpinfo 0 0 ); 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) : */ fun _clickE(a,m,x,y,button)= if recording /*|| playing*/ then ( stoprecsnd; _paintE nil nil ) /* else if udpserver!=nil && !strcmp udpserver "" then nil */ else if !silent then (startrecsnd; _paintE nil nil) else 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) : prise en compte longspeech */ fun _unclickE(a,m,x,y,button)= if !longspeech then ( stoprecsnd; _paintE nil nil ) else 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) : resize ObjWin not ObjText */ fun _resizeT(x,s)= let x->[_ x y w h] in _SIZEwindow winfo w h x y; 0;; fun _moveE(a,b,x,y,c)= _SETwinCursor win HandCursor;; /* creation de l'interface cliente une fois les 6 bitmaps dwl chez le client */ fun creaBitmap(i)= set cptBmp = cptBmp + i; if cptBmp == 6 then ( 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; _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; _CBcursorMove win2 @_moveE 0; _CBwinClick win2 @_clickE2 0); let _DMSgetZone this "Info" @_end @_resizeT @_end ->[win x y w h] in if win==nil then nil else (set winfo = _CRwindow _channel win x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "speaker"; _CBwinPaint winfo @_paintE 0; _paintE nil nil ); let substr recon (strlen recon)-4 4 -> extension in let substr recon (strlen recon)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then set bmpon = _LDjpeg _channel _checkpack recon else if !(strcmpi extension ".bmp") then set bmpon = _LDbitmap _channel _checkpack recon else nil; let substr recoff (strlen recoff)-4 4 -> extension in let substr recoff (strlen recoff)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then set bmpoff = _LDjpeg _channel _checkpack recoff else if !(strcmpi extension ".bmp") then set bmpoff = _LDbitmap _channel _checkpack recoff else nil; let substr playon (strlen playon)-4 4 -> extension in let substr playon (strlen playon)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then set bmppon = _LDjpeg _channel _checkpack playon else if !(strcmpi extension ".bmp") then set bmppon = _LDbitmap _channel _checkpack playon else nil; let substr playoff (strlen playoff)-4 4 -> extension in let substr playoff (strlen playoff)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then set bmppoff = _LDjpeg _channel _checkpack playoff else if !(strcmpi extension ".bmp") then set bmppoff = _LDbitmap _channel _checkpack playoff else nil; let substr playmute (strlen playmute)-4 4 -> extension in let substr playmute (strlen playmute)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then set bmppmute = _LDjpeg _channel _checkpack playmute else if !(strcmpi extension ".bmp") then set bmppmute = _LDbitmap _channel _checkpack playmute else nil; /* le background "winfo" est changeant : affiche le pseudo si quelqu'un parle ou laisse la texture d'origine si personne ne parle */ let substr bgbmp (strlen bgbmp)-4 4 -> extension in let substr bgbmp (strlen bgbmp)-5 5 -> extension2 in if !(strcmpi extension ".jpg") || !(strcmpi extension2 ".jpeg") then ( set jpgBmp = 1; bgLogin jpgBmp ) else if !(strcmpi extension ".bmp") then ( set jpgBmp = 0; bgLogin jpgBmp ) else nil; _paintE nil nil ) else nil ;; /* callbacks de dwl des bitmaps */ fun cbEndDownloadBmp1(s) = creaBitmap 1;0;; fun cbEndDownloadBmp2(s) = creaBitmap 1;0;; fun cbEndDownloadBmp3(s) = creaBitmap 1;0;; fun cbEndDownloadBmp4(s) = creaBitmap 1;0;; fun cbEndDownloadBmp5(s) = creaBitmap 1;0;; fun cbEndDownloadBmp6(s) = creaBitmap 1;0;; /* show interface */ fun cbShow(from, action, param, others, tag)= _SHOWwindow win WINDOW_UNHIDDEN; _SHOWwindow win2 WINDOW_UNHIDDEN; _SHOWwindow winfo WINDOW_UNHIDDEN; _DMSeventTag this "shown" nil nil nil; 0;; /* hide interface */ fun cbHide(from, action, param, others, tag)= _SHOWwindow win WINDOW_HIDDEN; _SHOWwindow win2 WINDOW_HIDDEN; _SHOWwindow winfo WINDOW_HIDDEN; _DMSeventTag this "hidden" nil nil nil; 0;; fun IniDMI(param)= set udpserver= /*if param!=nil && strcmp param "" then strcat strcat _channelIP DMSserver ":" param else param;*/ nil; let lineextr param -> [Precon[Precoff[Pplayon[Pplayoff[Pplaymute[Pbgbmp[Plspeech[Psf[Pfc _]]]]]]]]] in ( set recon = Precon; set recoff = Precoff; set playon = Pplayon; set playoff = Pplayoff; set playmute = Pplaymute; set bgbmp = Pbgbmp; set longspeech = atoi Plspeech; set sizefont = atoi Psf; set fontcolor = atoi Pfc ); set cptBmp = 0; _RSCdownload this recon recon @cbEndDownloadBmp1 0; _RSCdownload this recoff recoff @cbEndDownloadBmp2 1; _RSCdownload this playon playon @cbEndDownloadBmp3 1; _RSCdownload this playoff playoff @cbEndDownloadBmp4 1; _RSCdownload this playmute playmute @cbEndDownloadBmp5 1; _RSCdownload this bgbmp bgbmp @cbEndDownloadBmp6 1; _DMSregisterDMI this nil @before; _DMSdefineActions this (["show" @cbShow]):: (["hide" @cbHide])::nil; let getUdp 3000 4000->[c i] in (set udpport=i; set udp=c); 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) : ajout du login sur le bitmap info */ fun __sound (name,audio)= if silent then nil else (GetAudio name audio; bgLogin jpgBmp; let _GETbitmapSize bmpinfo -> [w h] in let _DRAWtext bmpinfo _CRfont _channel sizefont 0 0 "Arial" w/2 0 TD_CENTER fontcolor name -> bmpinfo2 in _BLTbitmap winfo bmpinfo2 1 1);;