//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 }
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 }
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 }
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] }
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) }