/* * Schnauzer : sound mode - C. Lorek 03/2001 */ var sound_name = "sound player 1.0";; var sound_exts = "WAV"::"MP3"::nil;; typeof snd_win = ObjWin;; typeof snd_src = ObjBitmap;; typeof snd_fname = S;; typeof snd_fsize = I;; typeof snd_w = I;; typeof snd_h = I;; typeof snd_dx = I;; typeof snd_dy = I;; typeof snd_dw = I;; typeof snd_dh = I;; typeof snd_ratio = F;; fun sound_load_by_name(s)= let _CRmulti _channel snd_win 0 0 0 0 _checkpack s nil -> snd in snd;; fun sound_calc_display(disp_w,disp_h)= let (itof disp_w) /. (itof snd_w) -> rx in let (itof disp_h) /. (itof snd_h) -> ry in let if (rx <. ry) then rx else ry -> r in let if (r >. (itof 1)) then (itof 1) else r -> r in let ftoi ((itof snd_w) *. r) -> w in let ftoi ((itof snd_h) *. r) -> h in { set snd_ratio = r; set snd_dx = (disp_w-w)/2; set snd_dy = (disp_h-h)/2; set snd_dw = w; set snd_dh = h; };; fun sound_repaint(obj,u)= /*if _platform then nil else _CLRwindow snd_win; _CLRwindow/win32 marche pas ... */ _STBLTbitmap snd_win snd_dx snd_dy snd_dw snd_dh snd_src 0 0 snd_w snd_h;; fun sound_status()= status_set strcatn snd_fname::" "::(itoa snd_w)::"x"::(itoa snd_h)::" ":: (itoa ftoi (snd_ratio *. itof 100))::"% (":: (itoa snd_fsize)::" bytes)"::nil;; fun sound_load(fname,win,x,y,w,h)= set snd_win = _CRwindow _channel win x y w h WN_CHILD|WN_NOBORDER nil; let sound_load_by_name fname -> snd in if (snd==nil) then { status_set strcat fname " : sound unsupported !"; 0 } else { set snd_fname = fname; set snd_fsize = file_size fname; _PLAYmulti snd; /* set snd_src = snd;*/ /* _CBwinPaint snd_win @sound_repaint nil; let _GETbitmapSize snd -> [u v] in { set snd_w=u; set snd_h=v; }; */ sound_calc_display w h; sound_repaint nil nil; sound_status; 1 };; fun sound_unload()= _DSwindow snd_win; _DSbitmap snd_src; 1;; fun sound_redim(x,y,w,h)= _POSITIONwindow snd_win x y w h; sound_calc_display w h; sound_repaint nil nil; sound_status; 1;; fun sound_init()= browser_add_types sound_exts strcat schnauzer_path "icones/sound.bmp"; schnauzer_register_mode sound_name sound_exts @sound_load @sound_unload @sound_redim;;