DECLARE FUNCTION PlaySound LIB "winmm.dll" ALIAS "PlaySoundA" (lpszName AS LONG, hModule AS LONG, dwFlags AS LONG) AS LONG
DECLARE SUB play
DIM soundstream AS QMEMORYSTREAM
application.title = "Test"
CREATE form AS QFORM
clientheight = 85
clientwidth = 120
center
borderstyle = 3
CAPTION = "Sound"
CREATE label AS QLABEL
top = 5
left = 5
width = 100
height = 15
CAPTION = "Volume:"
END CREATE
CREATE trackbar AS QTRACKBAR
top = 20
left = 5
width = 110
height = 22
tickstyle = 0
max = 100
position = 90
END CREATE
CREATE playbutton AS QCOOLBTN
CAPTION = "Play"
top = 55
left = 5
height = 25
width = 110
onclick = play
END CREATE
END CREATE
form.SHOWMODAL
SUB play
playbutton.CAPTION = "Wait..."
DOEVENTS
playsound(0, 0, 0)
soundstream.CLOSE
soundstream.writestr("RIFF", 4)
soundstream.writenum(640032, 4)
soundstream.writestr("WAVE", 4)
soundstream.writestr("fmt ", 4)
soundstream.writenum(16, 4)
soundstream.writenum(1, 2)
soundstream.writenum(2, 2)
soundstream.writenum(44100, 4)
soundstream.writenum(176400, 4)
soundstream.writenum(2, 2)
soundstream.writenum(16, 2)
soundstream.writestr("data", 4)
soundstream.writenum(640000, 4)
FOR t = 1 TO 160000
soundstream.writenum((COS(t / 51) XOR SIN(t / 150)) * (t / 160000) * (163.83 * trackbar.position), 2)
soundstream.writenum((SIN(t / 51) XOR COS(t / 150)) * ((160000 - t) / 160000) * (163.83 * trackbar.position), 2)
NEXT
playsound(soundstream.pointer, 0, 5)
playbutton.CAPTION = "Play"
END SUB
|