예제 #1
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
}
예제 #2
0
파일: jack.go 프로젝트: xthexder/go-jack
func (port *Port) MidiEventWrite(event *MidiData, buffer MidiBuffer) int {
	return int(C.jack_midi_event_write(
		unsafe.Pointer(buffer),                  // port_buffer
		C.jack_nframes_t(event.Time),            // time
		(*C.jack_midi_data_t)(&event.Buffer[0]), // data
		C.size_t(len(event.Buffer)),             // data_size
	))
}
예제 #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)
}