/* * Capture functions */ func CaptureOpenDevice(devicename string, frequency int, format ALCenum, buffersize int) *Device { s := alcString(devicename) d := (*Device)(C.alcCaptureOpenDevice( s, C.ALCuint(frequency), C.ALCenum(format), C.ALCsizei(buffersize))) freeString(s) return d }
func CaptureOpenDevice(name string, freq uint32, format Format, size uint32) *CaptureDevice { // TODO: turn empty string into nil? // TODO: what about an error return? p := C.CString(name) h := C.walcCaptureOpenDevice(p, C.ALCuint(freq), C.ALCenum(format), C.ALCsizei(size)) C.free(unsafe.Pointer(p)) return &CaptureDevice{Device{h}, uint32(format.SampleSize())} }
func CaptureOpenDevice(name string, freq uint32, format uint32, size uint32) *CaptureDevice { // TODO: turn empty string into nil? // TODO: what about an error return? p := C.CString(name) h := C.walcCaptureOpenDevice(p, C.ALCuint(freq), C.ALCenum(format), C.ALCsizei(size)) C.free(unsafe.Pointer(p)) s := map[uint32]uint32{FormatMono8: 1, FormatMono16: 2, FormatStereo8: 2, FormatStereo16: 4}[format] return &CaptureDevice{Device{h}, s} }
// Temporary, I have no idea what format this comes out in. // After I do I'll make something more sane func (dev Device) Attributes(size int) ([]int, error) { dest := make([]C.int, size) C.alcGetIntegerv(dev.device, C.ALC_ALL_ATTRIBUTES, C.ALCsizei(size), (*C.ALCint)(&dest[0])) toReturn := make([]int, size) for i, dat := range dest { toReturn[i] = int(dat) } return toReturn, GetError() }
func (device *Device) CaptureSamples(buffer interface{}, samples int) { C.alcCaptureSamples((*C.ALCdevice)(device), ptr(buffer), C.ALCsizei(samples)) }
func (self *CaptureDevice) CaptureStereo16To(data [][2]int16) { C.alcCaptureSamples(self.handle, unsafe.Pointer(&data[0]), C.ALCsizei(uint32(len(data))*4/self.sampleSize)) }
func (self *CaptureDevice) CaptureTo(data []byte) { C.alcCaptureSamples(self.handle, unsafe.Pointer(&data[0]), C.ALCsizei(uint32(len(data))/self.sampleSize)) }
func (self *Device) GetIntegerv(param uint32, size uint32) (result []int32) { result = make([]int32, size) C.walcGetIntegerv(self.handle, C.ALCenum(param), C.ALCsizei(size), unsafe.Pointer(&result[0])) return }
func (self *CaptureDevice) CaptureSamples(size uint32) (data []byte) { data = make([]byte, size*self.sampleSize) C.alcCaptureSamples(self.handle, unsafe.Pointer(&data[0]), C.ALCsizei(size)) return }
func (dev Device) AttributesSize() (int, error) { var dest *C.int C.alcGetIntegerv(dev.device, C.ALC_ATTRIBUTES_SIZE, C.ALCsizei(1), (*C.ALCint)(dest)) return int(*dest), GetError() }
func (dev Device) MinorVersion() (int, error) { var dest *C.int C.alcGetIntegerv(dev.device, C.ALC_MINOR_VERSION, C.ALCsizei(1), (*C.ALCint)(dest)) return int(*dest), GetError() }