-
Notifications
You must be signed in to change notification settings - Fork 45
/
al-example.go
51 lines (37 loc) · 1.05 KB
/
al-example.go
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
package main
import "openal/al"
import "openal/alc"
import "time"
import "fmt"
func main() {
out := alc.OpenDevice("")
fmt.Printf("%x\n", out.GetError())
con := out.CreateContext()
fmt.Printf("%x\n", out.GetError())
con.Activate()
fmt.Printf("%x\n", out.GetError())
in := alc.CaptureOpenDevice("", 8000, al.FormatMono16, 16000)
fmt.Printf("%x\n", in.GetError())
in.CaptureStart();
fmt.Printf("%x\n", in.GetError())
time.Sleep(1*1000*1000*1000)
in.CaptureStop()
fmt.Printf("%x\n", in.GetError())
n := in.GetInteger(alc.CaptureSamples)
fmt.Printf("n: %s\n", n)
fmt.Printf("%x\n", in.GetError())
raw := in.CaptureSamples(uint32(n)) // TODO get rid of cast
fmt.Printf("raw: %v\n", raw)
fmt.Printf("%x\n", in.GetError())
buf := al.NewBuffer()
fmt.Printf("%x\n", al.GetError())
buf.SetData(al.FormatMono16, raw, 8000)
fmt.Printf("%x\n", al.GetError())
src := al.NewSource()
fmt.Printf("%x\n", al.GetError())
src.SetBuffer(buf)
fmt.Printf("%x\n", al.GetError())
src.Play()
fmt.Printf("%x\n", al.GetError())
time.Sleep(1*1000*1000*1000)
}