/*O-REXX - Front End for OmniPlay*/ /*Version 1.0, (c) 1994 Aaron Weiss*/ call addlib("rexxreqtools.library", 0, -30, 0) call addlib("apig.library",0,-30,0) /* Set these two variables to reflect the proper paths as per the docs*/ oplay='sound:oplay' path='sounds:samples/' /*Note that the '/' must be there if path ends in a directory*/ address command 'resident oplay '||oplay||' PURE ADD' /*Don't change anything below this point*/ rate=0 volume=64 buff=4000 oneshot=0 channel='e' pause=0 propinfo=1 logtable=0 ulawmax=0 amplify=1 soundinfo=0 repeat=1 NL = '0a'x playone=0 flip=1 nofiles=0 Do Forever call pickfiles call pickchoices End address command 'resident oplay REMOVE' exit PickFiles: /*ask for filenames*/ drop files call rtfilerequest(path,,"Choose file(s) to play or enter pattern",,"rtfi_flags=freqf_multiselect",files) if (files==1) & (files.count>0) then do if index(files.1,"#?")~=0 Then do pathtmp=files.1 address command 'c:list '||files.1||' quick files TO t:O-REXX.tmp' call open infile,"t:O-REXX.tmp",read i=1 drop files filenames do until eof(infile) filename=readln(infile) files.i=filename tmpfile=filename mark=0 mark=LASTPOS("/",filename) if mark==0 then mark=lastpos(":",filename) if mark>0 then filenames.i=right(infile,length(filename)-mark) else filenames.i=filename mark=LASTPOS("/",pathtmp) if mark==0 then mark=lastpos(":",pathtmp) if mark>0 then files.i=left(pathtmp,mark)||files.i else files.i=pathtmp||files.i if right(filenames.i,5)~='.info' then i=i+1 end call close infile if i<4 then call pickfiles files.count=i-3 filenames.count=i-3 numchoices=files.count end else do do i=1 to files.count Infile=files.i Mark=0 Mark=LASTPOS("/",Infile) If Mark==0 Then Mark=LASTPOS(":",Infile) If Mark>0 Then filenames.i=Right(Infile,LENGTH(Infile)-Mark) numchoices=files.count end end end else nofiles=1 Mark=0 Mark=LASTPOS("/",files.1) if Mark==0 then Mark=LASTPOS(":",files.1) If Mark=0 Then pathhead='' Else pathhead=Left(files.1,Mark) return PickChoices: If files.count='FILES.COUNT' Then Do address command 'resident oplay REMOVE' Exit End /*rtezrequest('Sorry, you must choose at least one file!','Oops, sorry!') return End*/ Do Until choice==2 call rtezrequest('Welcome to O-REXX! Go ahead, choose an option...','All|New|Quit|Modify Settings|Play One|View Current Settings|Save file(s) as IFF') if rtresult==3 then Do address command 'resident oplay REMOVE' exit End if rtresult==0 then choice=7 else choice=rtresult cmdstring='oplay -r'||rate||' -v'||volume||' -b'||buff||' -o'||oneshot||' -c'||channel||' -w'||pause||' -s'||propinfo||' -g'||logtable||' -m'||ulawmax||' -a'||amplify||' -i'||soundinfo||' -OCON:0/0/640/120/O-REXX/AUTO/SIMPLE'||' -R'||repeat||' ' tmpstring=cmdstring Select When choice=1 Then Do do i=1 to files.count tmpstring=tmpstring||files.i||' ' end address command tmpstring End When choice==6 Then Do current='Playback Rate=' if rate>0 then current=current||rate||' Hz'||NL else current=current||'Use file info'||NL current=current||'Volume='||trunc((volume/64)*100,0)||'%%'||NL||'Amplitude='||amplify*100||'%%'||NL||'# Repeats='||Repeat||NL current=current||'Informativeness:' Select When (propinfo=0) & (soundinfo=0) Then current=current||"None"||NL When (propinfo=1) & (soundinfo=0) Then current=current||"Some"||NL When (propinfo=1) & (soundinfo=1) Then current=current||"Full"||NL Otherwise current=current||"Some"||NL End current=current||'----------'||NL current=current||'Buffer Size=' If buff=0 then current=current||'Entire File'||NL else current=current||buff||' bytes'||NL current=current||'Sound channel=' If channel='e' then current=current||'Either'||NL else if channel='l' then current=current||'Left'||NL else current=current||'Right'||NL current=current||'Pause between sounds='||pause/50||' seconds'||NL current=current||'Use Log Table? ' if logtable=0 then current=current||'No'||NL else current=current||'Yes'||NL current=current||'Display U-Law max? ' if ulawmax=0 then current=current||'No'||NL else current=current||'Yes'||NL rtezrequest(current,'Very nice','Current Settings') End When choice==5 Then Do exitone=0 first=1 Do while exitone=0 call selectone first=0 /*choice2=rtresult if choice2=0 then realchoice=numchoices else realchoice=choice2*/ tmpstring=tmpstring||files.realchoice if exitone=0 then address command tmpstring tmpstring='oplay -r'||rate||' -v'||volume||' -b'||buff||' -o'||oneshot||' -c'||channel||' -w'||pause||' -s'||propinfo||' -g'||logtable||' -m'||ulawmax||' -a'||amplify||' -i'||soundinfo||' -OCON:0/0/640/120/O-REXX/AUTO/SIMPLE'||' -R'||repeat||' ' End call CLOSEWINDOW(w1) call UNLOCKPUBSCREEN(null(),scr) call FREEVISUALINFO(scrvinfo) call FREEGADGETS(conxgad) call FREETHIS(newgadx) call FREEVEC(glistpointer) call FREE_EXEC_LIST(myexeclist,,1) End When choice==4 Then Do Flip=1 Call Settings End When choice==7 Then Do oldtmp=tmpstring tmpstring='oplay -r'||rate||' -v1 -b'||buff||' -o'||oneshot||' -c'||channel||' -w'||pause||' -s0 -g'||logtable||' -m'||ulawmax||' -a'||amplify||' -i0 -OCON:0/0/640/120/O-REXX/AUTO/SIMPLE'||' -R1 ' drop newpath newfile rtezrequest('Choose which file(s) you want to save as IFF','All|Select One') choice2=rtresult /*if choice2=0 then realchoice=numchoices else realchoice=choice2-1*/ if choice2=0 then do exitone=0 first=1 playone=1 do while exitone=0 call selectone first=0 if exitone=0 then do goahead=0 do while goahead=0 if goahead=0 then do writeover=0 newfile=rtfilerequest(path,filenames.realchoice||'.iff',"Save as what file?") result=rtresult Mark=0 Mark=LASTPOS("/",newfile) if Mark==0 then Mark=LASTPOS(":",newfile) If Mark=0 Then pathtmp='' Else pathtmp=Left(newfile,Mark) if (pathtmp=pathhead) & (right(newfile,length(filenames.realchoice))=filenames.realchoice) then do rtezrequest('Replace original file with new one?','Yes|No!',,'rtez_defaultresponse=0') if rtresult=1 then do goahead=1 writeover=1 end else goahead=0 end else goahead=1 end end if result=1 then do if writeover=1 then do tmpfile=newfile newfile=path||'orexx_temp' end tmpstring=tmpstring||'-W'||newfile||' '||files.realchoice||' ' call pitext(rpw1,305,50,('Saving...'),1,2,JAM1,null()) address command tmpstring if writeover=1 then do address command 'copy '||newfile||' '||tmpfile address command 'delete '||newfile end call pitext(rpw1,380,50,('Done'),1,2,JAM1,null()) delay (45) call cleareol(rpw1,305,50) end tmpstring='oplay -r'||rate||' -v1 -b'||buff||' -o'||oneshot||' -c'||channel||' -w'||pause||' -s0 -g'||logtable||' -m'||ulawmax||' -a'||amplify||' -i0 -OCON:0/0/640/120/O-REXX/AUTO/SIMPLE'||' -R1 ' end end playone=0 call CLOSEWINDOW(w1) call UNLOCKPUBSCREEN(null(),scr) call FREEVISUALINFO(scrvinfo) call FREEGADGETS(conxgad) call FREETHIS(newgadx) call FREEVEC(glistpointer) call FREE_EXEC_LIST(myexeclist,,1) end else do newpath=rtfilerequest(path,,"Where should I save the files?",,"rtfi_volumerequest=0") if rtresult=1 then do rtezrequest('Delete original files after saving?','Yes|No!',,'rtez_defaultresponse=0') delete=rtresult call OPEN out, "CON:0/0/640/200/O-REXX/AUTO/SIMPLE" do i=1 to files.count tmp2string=tmpstring tmp2string=tmp2string||'-W'||newpath||filenames.i||'.iff '||files.i call WRITELN out, "Saving "||filenames.i address command tmp2string if delete then do call WRITELN out, 'Deleting '||files.i address command 'delete >nil: ' files.i end end call CLOSE out end end End Otherwise NOP End tmpstring=oldtmp End return Playfiles: /*say 'sent command:'||tmpstring*/ ADDRESS command tmpstring return Settings: options.='nothing' options.1='Rate|Volume|Amp|Repeat|Info|More...|Exit Settings' options.2='Buffer|Channel|Pause|LogTable|ULawMax|Back...|Exit Settings' madechoice=0 Do until madechoice if picked=6 then flip=3-flip rtezrequest('Please select a setting to modify...',options.flip,,'rtez_defaultresponse=6') picked=rtresult if picked~=6 then madechoice=1 End If picked=0 Then Return If flip==1 Then Do Select When picked=1 Then Do rate1=rtgetlong(rate,'Enter new rate (in Hz)'||NL||'Note that 0 uses files built-in rate',,'Done','rtgl_min=0 rtgl_max=40000') if rate1~='' then rate=rate1 End When picked=2 Then Do volume1=rtgetlong(volume,'Enter new volume',,'Done','rtgl_min=0 rtgl_max=64') if volume1~='' then volume=volume1 End When picked=3 Then Do amplify1=rtgetlong(amplify,'Enter new amplification (whole integer, each 1=100%)',,'Done','rtgl_min=1') if amplify1~='' then amplify=amplify1 End When picked=4 Then Do repeat1=rtgetlong(repeat,'Play how many times?'||NL||'Note that 0 means do not play',,'Done') if repeat1~='' then repeat=repeat1 End When picked=5 Then Do rtezrequest('Please select how much information about the file you want','None|Some|Full',,'rtez_defaultresponse=3') Select When rtresult=1 then do propinfo=0 soundinfo=0 end When rtresult=2 then do propinfo=1 soundinfo=0 end Otherwise do propinfo=1 soundinfo=1 end End End End End Else Do Select When picked=1 Then Do ram=storage() buftmp=rtgetlong(buff,'Choose size of buffer in bytes'||NL||'Note that 0 will load entire file into RAM',,'Done','rtgl_min=0 rtgl_max='||ram) If buftmp~='' Then Do buff=buftmp if buff=0 then oneshot=1 else oneshot=0 End End When picked=2 Then Do chn=rtezrequest('Choose playback channel','Left|Either|Right',,'rtez_defaultresponse=2') select when chn=1 then channel='l' when chn=2 then channel='r' otherwise channel='e' end end When picked=3 Then Do pause1=rtgetlong(pause,'Choose pause time between successive plays'||NL||'Enter time in 1/50 second units',,'Done','rtgl_min=0') if pause1~='' then pause=pause1 End When picked=4 Then logtable=~(rtezrequest('Generate log tables for U-Law files?'||NL||'Note that this will result in long computation delays','No|Yes')) When picked=5 Then ulawmax=~(rtezrequest('Display U-Law maximum encoded value?'||NL||'For U-Law files that sound too low, check the U-Law max value.'||NL||'If it is less than 20,000 you might try using the Log table option','No|Yes')) End End Call Settings return Selectone: if first=1 then do call SET_APIG_GLOBALS() scr = LOCKPUBSCREEN("Workbench") /* gonna put our window */ /* Workbench screen */ scrvinfo = GETVISUALINFO(scr) /* NewGadgets need this */ scrfont = GETVALUE(scr,40,4,'p') /* NewGadgets need this */ /* points to TextAttr */ glistpointer = ALLOCVEC(4,MEMF_CLEAR) /* a pointer for context */ conxgad = CREATECONTEXT(glistpointer) previousgadget = conxgad myid = 10 /* we now create and initialize a NewGadget structure */ if playone=0 then reqtitle='Select a sound to play' else reqtitle='Select a sound to save as IFF' newgadx = MAKENEWGADGET(scrvinfo,scrfont,65,32,230,120,reqtitle, ,PLACETEXT_ABOVE,myid,null()) /* before doing the gadget creation we need an Exec List */ myexeclist = build_me_a_list() /* we now create the gadget, a LISTVIEW gadget */ previousgadget = CREATEGADGET(LISTVIEW_KIND,previousgadget,newgadx, ,GTLV_LABELS,myexeclist, ,LAYOUTA_SPACING,1, ,TAG_DONE,0) wintitle = "O-REXX Sound Selection" winidcmp = CLOSEWINDOW+GADGETUP+GADGETDOWN+MOUSEMOVE winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO, +ACTIVATE portname = "apiggadt3_port" p = openport(portname) /* open window, last parm in OPENWINDOW call points to our gadgets */ w1 = OPENWINDOW(portname,0,30,640,200,2,4,winidcmp,winflags,wintitle, ,scr,0,null(),null(),conxgad) call GT_REFRESHWINDOW(w1,null()) /* need after opening window */ rpw1 = GETWINDOWRASTPORT(w1) end exitme = 0 do while exitme = 0 x = waitpkt(portname) do forever msg = getpkt(portname) if msg = '0000 0000'x then leave msgclass = getarg(msg,0) msgcode = getarg(msg,1) x = reply(msg,0) select when MSGCLASS = CLOSEWINDOW then do exitone=1 exitme=1 end when msgclass = GADGETUP then do realchoice=msgcode+1 /* call cleareol(rpw1,290,50) call pitext(rpw1,290,50,("You clicked file" filenames.realchoice),1,2,,null())*/ exitme=1 end otherwise nop end end end return build_me_a_list: mylist = ALLOCMEM(14,MEMF_CLEAR) /* our list structure */ /* always use ALLOCMEM */ /* so it can be freed */ /* properly. */ call NEWLIST(mylist) do x = 1 to files.count txt = filenames.x ptr_to_node_added = ADD_LIST_NODE(mylist,txt) end return mylist