/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun cbDestroyEdit(p)= let p -> [[_ _ sndpreview] inst] in ( if (sndpreview == nil) then nil else audioPlayerDelete sndpreview; setPluginInstanceEditorCbPreRender inst nil; ); 0;; fun getEvents(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in set ndata = ["EVENT" elem]::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlsndname ctrlurl ctrlisurl ctrlloop ctrlenable ctrlvolume ctrlpitch ctrlenableeffect psnd ctrlevent] in ( let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else ( audioPlayerDelete sndpreview; mutate psnd <- [_ _ nil]; ); let getEdCtrlTextLineValue ctrlsndname -> sndpath in let getEdCtrlCheckState ctrlisurl -> isurl in let getEdCtrlTextLineValue ctrlurl -> url in let ftoi getEdCtrlFloatValue ctrlvolume -> volume in let getEdCtrlFloatValue ctrlpitch -> pitch in let getEdCtrlCheckState ctrlloop -> loop in let getEdCtrlCheckState ctrlenable -> enable in let getEdCtrlCheckState ctrlenableeffect -> enableeffect in let getEdCtrlListElems ctrlevent -> levent in ["path" sndpath]:: ["isurl" itoa isurl]:: ["url" url]:: ["volume" itoa volume]:: ["pitch" ftoa pitch]:: ["loop" itoa loop]:: ["enable" itoa enable]:: ["enableeffect" itoa enableeffect]:: (getEvents levent) );; fun cbEditorPreRender(inst, sessionstr, etime, psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else audioPlayerUpdate sndpreview;; fun updateMaxLenght(sndpreview, ctrladdpos)= let audioPlayerGetLength sndpreview -> length in setEdCtrlFloatMaxValue ctrladdpos length; 0;; fun cbDlgGetSound(pfile, p)= let p -> [inst ctrlbtn winstr ctrlsndname ctrlurl ctrlisurl psnd ctrladdpos ctrlvolume ctrlpitch] in ( if pfile == nil then nil else let _PtoScol pfile -> file in if file == nil then ( _DLGMessageBox _channel winstr.EDW_win (loc "OS3DSOUND_0001") (loc "OS3DSOUND_0012") 0; 0; ) else ( setEdCtrlTextLineValue ctrlsndname file; setEdCtrlTextLineValue ctrlurl nil; setEdCtrlCheckState ctrlisurl 0; let psnd -> [tbstr chkplaypause sndpreview] in ( if (sndpreview == nil) then nil else ( audioPlayerDelete sndpreview; mutate psnd <- [_ _ nil]; set sndpreview = nil; setEdToolBarCheckState tbstr chkplaypause 0; ); if (sndpreview != nil) then nil else ( let ftoi getEdCtrlFloatValue ctrlvolume -> volume in let getEdCtrlFloatValue ctrlpitch -> pitch in set sndpreview = audioPlayerCreate (strcat (getPluginInstanceName inst) "_preview") 1 0 volume pitch nil; mutate psnd <- [_ _ sndpreview]; audioPlayerOpenSound sndpreview file; ); updateMaxLenght sndpreview ctrladdpos; ); 0; ); setEdCtrlButtonEnable ctrlbtn 1; ); 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr ctrlsndname ctrlurl ctrlisurl psnd ctrladdpos ctrlvolume ctrlpitch] in let getEdCtrlTextLineValue ctrlsndname -> sndpath in let getPathFile sndpath "" -> [fpath fname] in ( setEdCtrlButtonEnable ctrlbtn 0; let _GETdesktopSize -> [sw sh] in let getEdWindowPos mainInterf.MINT_winMain -> [nx ny] in let getEdWindowSize mainInterf.MINT_winMain -> [nmw nmh] in let [750 450] -> [iw ih] in let crEdOpenFileDialog _channel winstr nx + ((nmw / 2) - (iw / 2)) ny + ((nmh / 2) - (ih / 2)) iw ih "" ["Sounds" "mp3"::"wav"::"ogg"::nil]::["MP3" "mp3"::nil]::["Ogg" "ogg"::nil]::["Wave" "wav"::nil]::["All" "*.*"::nil]::nil EDFILE_DIALOG_LIST_FOLDERS|EDFILE_DIALOG_SHOW_TOOLBAR nil sndpath -> dlgfstr in ( setEdWindowIcon dlgfstr.EDFD_dialog sWinDlgIcon; setEdOpenFileDialogCb dlgfstr mkfun2 @cbDlgGetSound [inst ctrlbtn winstr ctrlsndname ctrlurl ctrlisurl psnd ctrladdpos ctrlvolume ctrlpitch]; 0; ); ); 0;; fun cbEditVolumeChange(ctrl, value, psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else audioPlayerSetVolume sndpreview ftoi value; 0;; fun cbEditPitchChange(ctrl, value, psnd)= let psnd -> [_ _ sndpreview] in if (sndpreview == nil) then nil else audioPlayerSetPitch sndpreview value; 0;; fun cbEditPlayPause(tbstr, check, btn, mask, state, p)= let p -> [inst ctrlsndname ctrlurl ctrlisurl ctrlvolume ctrlpitch psnd] in let psnd -> [_ chkplaypause sndpreview] in let getEdCtrlTextLineValue (if (getEdCtrlCheckState ctrlisurl) then ctrlurl else ctrlsndname) -> sndpath in let ftoi getEdCtrlFloatValue ctrlvolume -> volume in let getEdCtrlFloatValue ctrlpitch -> pitch in ( if (state && (sndpath != nil)) then ( if (sndpreview != nil) then nil else ( set sndpreview = audioPlayerCreate (strcat (getPluginInstanceName inst) "_preview") 1 0 volume pitch nil; mutate psnd <- [_ _ sndpreview]; ); // Modification for URLs : check whether the source has changed every time the user clicks Play if (strcmp sndpath (audioPlayerGetCurrentSound sndpreview)) == 0 then nil else audioPlayerOpenSound sndpreview sndpath; audioPlayerSetVolume sndpreview volume; audioPlayerSetPitch sndpreview pitch; audioPlayerPlay sndpreview; ) else if (sndpreview != nil) then ( audioPlayerPause sndpreview; ) else ( setEdToolBarCheckState tbstr chkplaypause 0; nil; ) ); 0;; fun cbEditSetupStop(tbstr, check, btn, mask, psnd)= let psnd -> [tbstr chkplaypause sndpreview] in if (sndpreview == nil) then nil else ( audioPlayerDelete sndpreview; mutate psnd <- [_ _ nil]; setEdToolBarCheckState tbstr chkplaypause 0; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun cbCheckUrl(ctrl, state, p)= let p -> [ctrlurl ctrlpath pickbtn] in if state then ( setEdCtrlTextLineEnable ctrlurl 1 ; setEdCtrlTextLineValue ctrlpath nil; setEdCtrlButtonEnable pickbtn 0; ) else ( setEdCtrlTextLineEnable ctrlurl 0; setEdCtrlButtonEnable pickbtn 1; ); 0;; fun cbAddActEvnt(ctrlstr, value, p)= let p -> [liststr ctrladdpos ctrladdevent] in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in let ftoa (getEdCtrlFloatValue ctrladdpos) -> fpos in if (isStringInListi lelem (strcatn fpos::" "::value::nil)) then nil else ( addEdCtrlList liststr (strcatn fpos::" "::value::nil) nil nil; setEdCtrlTextLineValue ctrlstr nil; ); 0;; fun cbAddList(ctrlstr, p)= let p -> [liststr ctrladdpos ctrladdevent] in let getEdCtrlTextLineValue ctrladdevent -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let ftoa (getEdCtrlFloatValue ctrladdpos) -> fpos in let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem (strcatn fpos::" "::value::nil)) then nil else ( addEdCtrlList liststr (strcatn fpos::" "::value::nil) nil nil; setEdCtrlTextLineValue ctrladdevent nil; ); 0;; fun cbDelList(ctrlstr, p)= let p -> [liststr ctrladdpos ctrladdevent] in let getSelectedEdCtrlList liststr -> [name _ _] in delEdCtrlList liststr name; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [420 385] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "path") -> sndpath in let atoi (getPluginInstanceParam inst "isurl") -> isurl in let if isurl == nil then 0 else isurl -> isurl in let (getPluginInstanceParam inst "url") -> url in let if url == nil then "http://" else url -> url in let atoi (getPluginInstanceParam inst "loop") -> loop in let if loop == nil then 0 else loop -> loop in let atoi (getPluginInstanceParam inst "enable") -> enable in let if enable == nil then 0 else enable -> enable in let atof (getPluginInstanceParam inst "volume") -> volume in let if volume == nil then 100.0 else volume -> volume in let atof (getPluginInstanceParam inst "pitch") -> pitch in let if pitch == nil then 1.0 else pitch -> pitch in let atoi (getPluginInstanceParam inst "enableeffect") -> enableeffect in let crEdFrameWindow _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DSOUND_0009") (loc "OS3DSOUND_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 145 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 100 20 (loc "OS3DSOUND_0014") EDWIN_RESIZE_MW -> ctrlisurl in let crEdCtrlTextLine winstr 180 ypos (iw - 200) 20 url nil EDWIN_RESIZE_MW -> ctrlurl in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSOUND_0007") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 170 20 sndpath nil EDWIN_RESIZE_MW -> ctrlsndname in let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> filebtn in let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshsndname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSOUND_0010") nil -> labelvol in let crEdCtrlFloat winstr 180 ypos 100 20 volume 0.0 400.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlvolume in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSOUND_0008") nil -> labelpitch in let crEdCtrlFloat winstr 180 ypos 100 20 pitch 0.0 10.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlpitch in let crEdWindowToolBar winstr 0 (set ypos = ypos + 30) iw 28 5 1 0x373737 ETB_HORIZONTAL -> tbstr in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_playpause.png" -> aplaypause in let crEdToolBarCheck tbstr aplaypause ETB_ALIGN_LEFT (loc "OS3DSOUND_0004") nil -> chkplaypause in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_stop.png" -> astop in let crEdToolBarButton tbstr astop ETB_ALIGN_LEFT (loc "OS3DSOUND_0011") nil -> chkstop in let crEdFrameWindow _channel ewinstr 0 0 iw 120 EDWIN_RESIZE_MW nil (loc "OS3DSOUND_0015") (loc "OS3DSOUND_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 100 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlList winstr 10 (set ypos = 10) (iw - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlevent in let crEdCtrlFloat winstr 10 (set ypos = ypos + 65) 100 20 0.0 0.0 1.0 0.01 6 nil EDWIN_RESIZE_MW -> ctrladdpos in let crEdCtrlTextLine winstr 115 ypos (iw - 175) 20 nil nil EDWIN_RESIZE_MW -> ctrladdevent in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd1 in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel1 in let crEdFrameWindow _channel ewinstr 0 0 iw 105 EDWIN_RESIZE_MW nil (loc "OS3DSOUND_0003") (loc "OS3DSOUND_0002") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DSOUND_0005") EDWIN_RESIZE_MW -> ctrlloop in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DSOUND_0013") nil -> ctrlenableeffect in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DSOUND_0006") EDWIN_RESIZE_MW -> ctrlenable in let audioPlayerCreate (strcat (getPluginInstanceName inst) "_preview") 1 0 (ftoi volume) pitch nil -> sndpreview in let [tbstr chkplaypause sndpreview] -> psnd in ( setEdToolBarVisible tbstr 1; paintEdToolBar tbstr; let if (isurl) then url else sndpath -> sndpath in audioPlayerOpenSound sndpreview sndpath; updateMaxLenght sndpreview ctrladdpos; setEdToolBarCheckCbClick tbstr chkplaypause mkfun6 @cbEditPlayPause [inst ctrlsndname ctrlurl ctrlisurl ctrlvolume ctrlpitch psnd]; setEdToolBarButtonCbClick tbstr chkstop mkfun5 @cbEditSetupStop psnd; setEdCtrlFloatCbChange ctrlvolume mkfun3 @cbEditVolumeChange psnd; setEdCtrlFloatCbChange ctrlpitch mkfun3 @cbEditPitchChange psnd; setEdCtrlCheckState ctrlloop loop; setEdCtrlCheckState ctrlenable enable; setEdCtrlCheckState ctrlenableeffect enableeffect; setEdCtrlCheckState ctrlisurl isurl; // fillEdCtrlList ctrlevent levent; setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList [ctrlevent ctrladdpos ctrladdevent]; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList [ctrlevent ctrladdpos ctrladdevent]; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt [ctrlevent ctrladdpos ctrladdevent]; // setEdCtrlButtonCb filebtn mkfun2 @cbBtnPickObj [inst winstr ctrlsndname ctrlurl ctrlisurl psnd ctrladdpos ctrlvolume ctrlpitch]; setEdCtrlCheckCbState ctrlisurl mkfun3 @cbCheckUrl [ctrlurl ctrlsndname filebtn]; setEdCtrlTextLineEnable ctrlsndname 0; setEdCtrlButtonCb refreshsndname mkfun2 @cbRefreshBtn [ctrlsndname]; setPluginInstanceEditorCbPreRender inst mkfun4 @cbEditorPreRender psnd; if !isurl then ( setEdCtrlTextLineEnable ctrlurl 0; setEdCtrlButtonEnable filebtn 1; ) else ( setEdCtrlTextLineEnable ctrlurl 1; setEdCtrlButtonEnable filebtn 0; ); [mkfun1 @cbCloseEdit [ctrlsndname ctrlurl ctrlisurl ctrlloop ctrlenable ctrlvolume ctrlpitch ctrlenableeffect psnd ctrlevent] mkfun1 @cbDestroyEdit [psnd inst]]; ); );;