示例#1
0
//export jackClientCallback
func jackClientCallback(nframes C.jack_nframes_t, arg unsafe.Pointer) C.int {
	jc := (*JackClient)(arg)

	// Check for no callback set.
	if jc.callback == nil {
		return 0
	}

	var cArr *C.float
	length := int(nframes)

	for i, port := range jc.jackIn {
		cArr = (*C.float)(C.jack_port_get_buffer(port, nframes))
		cArrayToSlice32f(cArr, length, &jc.bufIn[i])
	}
	for i, port := range jc.jackOut {
		cArr = (*C.float)(C.jack_port_get_buffer(port, nframes))
		cArrayToSlice32f(cArr, length, &jc.bufOut[i])
	}

	if err := jc.callback(jc.bufIn, jc.bufOut); err != nil {
		return 1
	}

	return 0
}
示例#2
0
文件: Port.go 项目: kkroening/gojack
func (this *Port) GetBuffer(frameCount FrameCount) (unsafe.Pointer, error) {
	var err error
	buffer := C.jack_port_get_buffer(this.jackPort, C.jack_nframes_t(frameCount))
	if buffer == nil {
		err = errors.New("jack_port_get_buffer failed for port '" + this.GetName() + "'")
	}
	return buffer, err
}
示例#3
0
文件: jack.go 项目: xthexder/go-jack
func (port *Port) GetMidiEvents(nframes uint32) []*MidiData {
	var event C.jack_midi_event_t
	samples := C.jack_port_get_buffer(port.handler, C.jack_nframes_t(nframes))
	nEvents := uint32(C.jack_midi_get_event_count(samples))
	events := make([]*MidiData, nEvents, nEvents)
	for i := range events {
		C.jack_midi_event_get(&event, samples, C.uint32_t(i))
		buffer := C.GoBytes(unsafe.Pointer(event.buffer), C.int(event.size))
		events[i] = &MidiData{
			Time:   uint32(event.time),
			Buffer: buffer,
		}
	}
	return events
}
示例#4
0
文件: jack.go 项目: padster/go-jack
func (port *Port) GetBuffer(nframes uint32) []AudioSample {
	samples := C.jack_port_get_buffer(port.handler, C.jack_nframes_t(nframes))
	return (*[1 << 30]AudioSample)(samples)[:nframes:nframes]
}
示例#5
0
文件: jack.go 项目: xthexder/go-jack
func (port *Port) MidiClearBuffer(nframes uint32) MidiBuffer {
	buffer := C.jack_port_get_buffer(port.handler, C.jack_nframes_t(nframes))
	C.jack_midi_clear_buffer(buffer)
	return MidiBuffer(buffer)
}