/
sox.go
105 lines (86 loc) · 1.61 KB
/
sox.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package sox
//#include <sox.h>
//#cgo LDFLAGS: -lsox
import "C"
//import "unsafe"
import "fmt"
/*
Find and load format handler plugins.
*/
func FormatInit() int {
return int(C.sox_format_init())
}
/*
Unload format handler plugins.
*/
func FormatQuit() {
C.sox_format_quit()
}
/*
Initialize effects library.
*/
func Init() int {
return int(C.sox_init())
}
/*
Close effects library and unload format handler plugins.
*/
func Quit() int {
return int(C.sox_quit())
}
/*
Search for effect by name. nil is returned if nothing found.
*/
func FindEffect(name string) *Effect {
return newEffect(C.sox_find_effect(C.CString(name)))
}
func newEffect(eh *C.sox_effect_handler_t) *Effect {
if eh == nil {
return nil
}
return &Effect{
Name: C.GoString(eh.name),
Usage: C.GoString(eh.usage),
effect: eh,
}
}
type Effect struct {
Name string
Usage string
Flags uint
effect *C.sox_effect_handler_t
}
func (e *Effect) cEffect() (eh *C.sox_effect_handler_t) {
if e.effect != nil {
eh = e.effect
}
eh.name = C.CString(e.Name)
eh.usage = C.CString(e.Usage)
eh.flags = C.uint(e.Flags)
return eh
}
/*
Returns the table of format handler names and functions.
*/
func formatFns() (hurr []string) {
var format_tabs *C.sox_format_tab_t
format_tabs = C.sox_get_format_fns()
fmt.Printf("%#v\n", format_tabs)
fmt.Printf("%#v\n", format_tabs.name)
return
}
type Format struct {
}
func (f *Format) AddEffect(e Effect) error {
return nil
}
func (f *Format) Read(p []byte) (n int, err error) {
return
}
func (f *Format) Close() (err error) {
return nil
}
type formatTab struct {
Name string
fn C.sox_format_fn_t
}