Exemple #1
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
}
Exemple #2
0
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
	))
}
Exemple #3
0
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
}
Exemple #4
0
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]
}
Exemple #5
0
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)
}