forked from SayCV/GarageEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AudioClip.go
56 lines (50 loc) · 1.2 KB
/
AudioClip.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
package audio
import (
//"errors"
//"github.com/skarr/GarageEngine/engine"
"github.com/vova616/go-openal/openal"
)
type Format int
type DistanceModel uint32
const (
Mono8 = Format(iota)
Mono16 = Format(iota)
Stereo8 = Format(iota)
Stereo16 = Format(iota)
)
const (
InverseDistance = DistanceModel(openal.InverseDistance)
InverseDistanceClamped = DistanceModel(openal.InverseDistanceClamped)
LinearDistance = DistanceModel(openal.LinearDistance)
LinearDistanceClamped = DistanceModel(openal.LinearDistanceClamped)
ExponentDistance = DistanceModel(openal.ExponentDistance)
ExponentDistanceClamped = DistanceModel(openal.ExponentDistanceClamped)
)
func (f Format) AlFormat() openal.Format {
switch f {
case Mono8:
return openal.FormatMono8
case Mono16:
return openal.FormatMono16
case Stereo8:
return openal.FormatStereo8
case Stereo16:
return openal.FormatStereo16
}
panic("Unkown format")
}
type AudioClip interface {
/*
Buffer size in int16 required to pass to NextBuffer
*/
BufferLength() int
NextBuffer([]int16, bool) int
Clone() (AudioClip, error)
/*
Samples in this clip
*/
Length() int
SampleRate() int
SetPosition(int)
AudioFormat() Format
}