-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
AudDemo.exw
63 lines (45 loc) · 1.19 KB
/
AudDemo.exw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
without warning
include std/machine.e
include EuSys2.ew
include EuGfx2.ew
include EuAud2.ew
include sfFlags.e
constant event = allocate(4 * 6)
atom win = sfRenderWindow_create(800,600,32,"My Window - Audio",sfClose,0)
if win = -1 then
puts(1,"Could not create render window!\n")
abort(0)
end if
atom snd = sfMusic_createFromFile("Test.wav")
sfMusic_setVolume(snd,100.0)
if snd = -1 then
puts(1,"Could not create/load sound!\n")
abort(0)
end if
integer played = 0
while sfRenderWindow_isOpen(win) do
while sfRenderWindow_pollEvent(win,event) do
atom eventType = peek4s(event)
atom code = peek4s(event+4)
atom alt = peek4s(event+8)
atom control = peek4s(event+14)
atom shift = peek4s(event+16)
atom system = peek4s(event+20)
if eventType = sfEvtKeyPressed then
if code = sfKeyEscape then
sfRenderWindow_close(win)
end if
elsif eventType = sfEvtClosed then
sfRenderWindow_close(win)
end if
end while
sfRenderWindow_clear(win,sfBlack)
if played = 0 then
sfMusic_play(snd)
played = 1
end if
sfRenderWindow_display(win)
end while
sfMusic_destroy(snd)
sfRenderWindow_destroy(win)
39.6