-
Notifications
You must be signed in to change notification settings - Fork 45
/
example.go
65 lines (43 loc) · 1.27 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import "openal"
import "fmt"
import "time"
func main() {
dev := openal.OpenDevice("");
fmt.Printf("dev: %s\n", dev);
err := dev.GetError();
fmt.Printf("err: %s\n", err);
con := dev.CreateContext();
fmt.Printf("con: %s\n", con);
err = dev.GetError();
fmt.Printf("err: %s\n", err);
ok := con.MakeContextCurrent();
fmt.Printf("MakeContextCurrent ok: %s\n", ok);
con.DestroyContext();
fmt.Println("Context destroyed!");
// according to the OpenAL 1.1 spec this should have
// resulted in an error; hmmm...
err = dev.GetError();
fmt.Printf("err: %s\n", err);
ok = dev.CloseDevice();
fmt.Printf("CloseDevice ok: %s\n", ok);
mic := openal.CaptureOpenDevice("", 8000, openal.AlFormatMono16, 16000);
fmt.Printf("mic: %s\n", mic);
err = mic.GetError();
fmt.Printf("err: %s\n", err);
mic.CaptureStart();
fmt.Println("capture started!");
err = mic.GetError();
fmt.Printf("err: %s\n", err);
fmt.Println(time.Sleep(1*1000*1000*1000));
smp := mic.GetInteger(openal.AlcCaptureSamples);
fmt.Printf("smp: %s\n", smp);
buf := mic.CaptureSamples(smp);
fmt.Printf("buf: %v\n", buf);
mic.CaptureStop();
fmt.Println("capture stopped!");
err = mic.GetError();
fmt.Printf("err: %s\n", err);
ok = mic.CaptureCloseDevice();
fmt.Printf("ok: %s\n", ok);
}