aUCBLogo Demos and Tests / playwavs
to playwavs
changeDir "C:\Windows\Media
l=[]
foreach (Files [*.wav])
[ l=lPut (word ?) l
]
ignore
[ foreach shell [dir *.wav /OEN /B]
[ if not empty? ?
[ if legalchars (word ?)
[ l=lput (word ?) l
]
]
]
]
N=count l
w=array N
repeat N
[ w.repCount=loadWav l.repCount
]
(pr [Playing mixed random sounds loaded to memory until a key is pressed...])
running=true
while [running]
[ w1=w.(1+random N)
w2=w.(1+random N)
mix=lShift w1+w2 -1
setHeader mix w1 w1
playWave mix 8
if key? [running=false]
GC
]
ignore readChar
playWave [] 0
(pr [Press a..z to play a sound. ESC stops.])
running=true
while [running]
[ ch=rawASCII readChar
if ch==27 [running=false]
if ch>=97 and2 ch<=97+N
[ playWaveFast w.(ch-96)
]
]
playWave [] 0
changeDir "C:\aUCBLogo
end
to loadWav f
local [size wav]
openReadBin f
setReader f
size=fileSize f
wav=readInt16ArrayBin size/2
setReader []
close f
(pr f "loaded)
output wav
end
to legalchars w
repeat count w
[ if (rawASCII item repCount w) > 127
[ output false
]
]
output true
end
to setHeader out in1 in2
ifelse (count in1) < (count in2)
[ repeat 64
[ out.repCount=in1.repCount
]
][ repeat 64
[ out.repCount=in2.repCount
]
]
end