-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchannel_areas.go
58 lines (48 loc) · 1.23 KB
/
channel_areas.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
/*
* Copyright (c) 2019 Zenichi Amano
*
* This file is part of libsoundio, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
package soundio
/*
#include <soundio/soundio.h>
*/
import "C"
import (
"unsafe"
)
// ChannelAreas contain channel datas.
type ChannelAreas struct {
areas []*ChannelArea
channelCount int
frameCount int
}
// ChannelCount returns channel count.
func (a *ChannelAreas) ChannelCount() int {
return a.channelCount
}
// FrameCount returns frame count.
func (a *ChannelAreas) FrameCount() int {
return a.frameCount
}
// Area returns ChannelArea.
func (a *ChannelAreas) Area(channel int) *ChannelArea {
return a.areas[channel]
}
// Buffer returns ChannelArea buffer.
func (a *ChannelAreas) Buffer(channel int, frame int) []byte {
return a.areas[channel].bufferWithFrame(frame)
}
func newChannelAreas(ptr *C.struct_SoundIoChannelArea, format Format, chanelCount int, frameCount int) *ChannelAreas {
areasPtr := uintptr(unsafe.Pointer(ptr))
areas := make([]*ChannelArea, chanelCount)
for ch := 0; ch < chanelCount; ch++ {
areas[ch] = newChannelArea(areasPtr, format, ch, frameCount)
}
return &ChannelAreas{
areas: areas,
channelCount: chanelCount,
frameCount: frameCount,
}
}