home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
sounds
/
wave11r3
/
WAVEMOD.OPL
< prev
next >
Wrap
Text File
|
1995-02-13
|
17KB
|
936 lines
REM *** (c) 1993,4,5 Takoyaki Software Ltd ***
REM *** Programmed by Dylan Cuthbert ***
APP WaveMod
TYPE $1002
PATH "\WVE"
EXT "WVE"
ICON "\opd\wavemod.pic"
ENDA
PROC wavemod:
global fname$(128),iadd
global wwin%,vol%,swin%,bwin%
global tf$(128),buf%(512),b%
global rperc1&,rperc2&,chg%
global bf$(128),bfn$(128)
global ct%(4098),et%(256)
global reg%,reg$(32),sp,sl
global fillen&,filthr&
rem *** Change reg% to 1 for registered version
reg%=1
reg$="Dylan Cuthbert"
cache 4096,4096
cls
rem *** make sure the various directories exist
trap mkdir "\WVE"
trap mkdir "\OPD"
setpath "\wve\"
fname$="*.wve"
rem *** set the temporary file's name
tf$="\OPD\wm_temp.tmp"
rem *** set the backup file's name
bf$="\OPD\backup.tmp"
b%=addr(buf%(1))
rem *** load up the modules
loadm "\OPO\wavefunc.opo"
loadm "\OPO\waveshow.opo"
loadm "\OPO\wavetabs.opo"
rem *** generate the A-law compression/decompression tables
gentabs:
fname$=cmd$(2)
if cmd$(3)="C"
if newwave%:(fname$) = 0 : return : endif
endif
swin%=gcreate (0,100+34,gwidth,16,1)
wwin%=gcreate (0,32,gwidth,100,1)
showwave:(fname$)
if reg%=0 : showinfo: : endif
selarea:
trap delete tf$
trap delete bf$
endp
rem *** cut a section out of a sample
proc scut:(in$,out$,rx,rw)
local hdr%(16),in%,out%,h%
local len&,ret%,px&,pw&
h%=addr(hdr%(1))
ioopen(in%,in$,$600)
ioopen(out%,out$,$102)
ioread(in%,h%,32)
len&=peekl(uadd(h%,18))
pokel uadd(h%,18),int(rw)
pokew uadd(h%,24),0
pokew uadd(h%,22),0
iowrite(out%,h%,32)
px&=rx+32 : pw&=rw
while pw&>0
ioseek(in%,1,px&)
ret%=ioread(in%,b%,1024)
if ret%=0 : break : endif
px&=px&+ret%
if pw&<1024
iowrite(out%,b%,pw&)
else
iowrite(out%,b%,1024)
endif
pw&=pw&-1024
endwh
ioclose(in%) : ioclose(out%)
endp
rem *** insert into a sample
proc sins:(in$,in2$,rx,rw,delin2%)
local hdr%(16),in%,in2%,tmp%,h%
local len&,len2&,ret%,px&,pw&
local fn$(130),inp&,n&,hdr2%(16),h2%
h%=addr(hdr%(1))
h2%=addr(hdr2%(1))
ret% = ioopen(in%,in$,$600) rem *** File to insert into
if ret%<0 : showerr:(ret%) : return : endif
ret% = ioopen(in2%,in2$,$600) rem *** File to insert
if ret%<0 : showerr:(ret%) : return : endif
ret% = ioopen(tmp%,addr(fn$),$104) rem *** File to output to
if ret%<0 : showerr:(ret%) : return : endif
rem *** Read the 32 byte sound file header
ioread(in%,h%,32)
ioread(in2%,h2%,32)
len&=peekl(uadd(h%,18))
len2&=peekl(uadd(h2%,18))
if rw<>0 and len2&>rw
len2&=int(rw)
endif
rem *** Modify the length
pokel uadd(h%,18),len2&+len&
iowrite(tmp%,h%,32)
px&=32 : inp&=32 : n&=int(rx)
rem *** Copy beginning of file
while n&>0
ioseek(in%,1,px&)
if n&>1024
ret%=ioread(in%,b%,1024)
else
ret%=ioread(in%,b%,n&)
endif
iowrite(tmp%,b%,ret%)
px&=px&+ret% : n&=n&-ret%
endwh
rem *** Copy paste buffer in
n&=len2&
while n&>0
ioseek(in2%,1,inp&)
if n&>1024
ret%=ioread(in2%,b%,1024)
else
ret%=ioread(in2%,b%,n&)
endif
iowrite(tmp%,b%,ret%)
inp&=inp&+ret% : n&=n&-ret%
endwh
rem *** Copy rest of file ***
while 1
ioseek(in%,1,px&)
ret%=ioread(in%,b%,1024)
if ret%<=0 : break : endif
iowrite(tmp%,b%,ret%)
px&=px&+ret%
endwh
ioclose(tmp%)
ioclose(in%)
ioclose(in2%)
if delin2%=1 : delete in2$ : endif
trap copy fn$,in$
if err
giprint "Disk full!"
endif
delete fn$
endp
rem *** delete a section of a sample
proc sdel:(in$,rx,rw)
local hdr%(16),in%,tmp%,h%
local len&,ret%,px&,pw&
local fn$(130),n&
h%=addr(hdr%(1))
ret% = ioopen(in%,in$,$600) rem *** File to insert into
if ret%<0 : showerr:(ret%) : return : endif
ret% = ioopen(tmp%,addr(fn$),$104) rem *** File to output to
if ret%<0 : showerr:(ret%) : return : endif
rem *** Read the 32 byte sound file header
ioread(in%,h%,32)
len&=peekl(uadd(h%,18))
rem *** Modify the length
pokel uadd(h%,18),len&-rw
iowrite(tmp%,h%,32)
px&=32 : n&=int(rx)
rem *** Copy beginning of file
while n&>0
ioseek(in%,1,px&)
if n&>1024
ret%=ioread(in%,b%,1024)
else
ret%=ioread(in%,b%,n&)
endif
iowrite(tmp%,b%,ret%)
px&=px&+ret% : n&=n&-ret%
endwh
px&=px&+rw
rem *** Copy rest of file ***
while 1
ioseek(in%,1,px&)
ret%=ioread(in%,b%,1024)
if ret%<=0 : break : endif
iowrite(tmp%,b%,ret%)
px&=px&+ret%
endwh
ioclose(tmp%) : ioclose(in%)
copy fn$,in$
delete fn$
endp
rem *** play a sample (taken from OPL manual)
proc playw:(inname$,ticks%,vol%)
local name$(128),p%,ret%
p%=peekw($1c)+6
name$=inname$+chr$(0)
ret%=call ($1f86, uadd(addr(name$),1),ticks%,vol%)
if peekw(p%) and 1
return ret% or $ff00
endif
endp
rem *** set up the header for a new sample file
proc newwave%:(n$)
local s$(16),ret%,hdr%(17),h%,f%
s$="ALawSoundFile**"
sp=0 : sl=0
h%=addr(hdr%(2))
if ioopen(f%,n$,$101)=0
poke$ usub(h%,1),s$
pokew uadd(h%,16),$100f
iowrite(f%,h%,32)
ioclose(f%)
chg%=0
return 1
else
return 0
endif
endp
rem *** open an existing sample
proc openwave:(p$)
local d%,f%
if p$="O" : f%=64 : endif
if p$="C" : f%=1+8 : endif
dinit "Waveform?"
dfile fname$,"File:",f%
if dialog
if not exist(fname$)
d%=newwave%:(fname$)
else
sp=0 : sl=0
d%=1
endif
else
d%=0
endif
if d%=1
chg%=0
endif
return d%
endp
rem *** as copied from OPL manual
PROC recordw:(i$,s%)
local n$(128),p%,r%
p%=peekw($1c)+6
n$=i$+chr$(0)
r%=call($2286,uadd(addr(n$),1),s%)
if peekw(p%) and 1
return r% or $ff00
endif
ENDP
proc setvol:
vol%=vol%+1
dinit "Set Volume"
dchoice vol%,"Volume:","Loud,Semi-Loud,Medium,Semi-Low,Low"
dialog
vol%=vol%-1
endp
rem *** process a region with the specified function
proc function:(in$,func$,rx,rw)
local hdr%(16),in%,tmp%,h%
local len&,ret%,px&,pw&,err%
local fn$(130),n&,total&,rw&
h%=addr(hdr%(1))
ret% = ioopen(in%,in$,$600) rem *** File to insert into
if ret%<0 : showerr:(ret%) : return : endif
ret% = ioopen(tmp%,addr(fn$),$104) rem *** File to output to
if ret%<0 : showerr:(ret%) : return : endif
busy "Processing..."
rem *** Read the 32 byte sound file header
ioread(in%,h%,32)
len&=peekl(uadd(h%,18))
if rw=0 : rw&=len& : else : rw&=int(rw) : endif
px&=32 : n&=rx : total&=n&
rem *** Copy beginning of file
while n&>0
ioseek(in%,1,px&)
ret%=readbuf%:(in%,n&)
iowrite(tmp%,b%,ret%)
px&=px&+ret% : n&=n&-ret%
endwh
total&=total&+@&(func$):(in%,tmp%,px&,rw&)
px&=0 : ioseek(in%,3,px&) : rem get current pos in file
rem *** Copy rest of file ***
while 1
ioseek(in%,1,px&)
ret%=ioread(in%,b%,1024)
if ret%<=0 : break : endif
iowrite(tmp%,b%,ret%)
px&=px&+ret% : total&=total&+ret%
endwh
ioclose(tmp%) : ioclose(in%)
if sp+sl>total&
if sp<>0 : sl=total&-sp : else : sl=0 : endif
endif
rem *** Now to copy the temporary file over and delete it ***
ioopen(tmp%,fn$,$600)
ioopen(in%,in$,$102)
pokel uadd(h%,18),total&
iowrite(in%,h%,32)
n&=total&
while n&>0
ret%=readbuf%:(tmp%,n&)
iowrite(in%,b%,ret%)
n&=n&-ret%
endwh
ioclose(tmp%) : ioclose(in%)
delete fn$
busy off
endp
proc readbuf%:(in%,n&)
return readbfn%:(in%,n&,int(1024))
endp
proc readbfn%:(in%,n&,len&)
local ret%
if n&>len&
ret%=ioread(in%,b%,len&)
else
ret%=ioread(in%,b%,n&)
endif
if ret%<0 : ret%=0 : endif
return ret%
endp
proc readj:(cx&)
local nx%
if iadd : nx%=(cx&-sp)/iadd : else : nx%=gwidth/2 : endif
return nx%
endp
proc readjw:(cx&)
local nx%
nx%=1
if iadd : nx%=cx&/iadd : endif
if nx%=0 : nx%=1 : endif
return nx%
endp
proc bakchk:
local d%
if chg%=0
dinit
dtext "","Make a backup copy before continuing?",2
dbuttons "No",%n,"Yes",%y
d%=dialog
if d%=0 : return 0 : endif
if d%=%y
trap copy fname$,bf$
if err
giprint "Una