// Write writes a buffer of MIDI events to the output stream. func (s *Stream) Write(events []Event) error { size := len(events) if size > maxEventBufferSize { return ErrMaxBuffer } buffer := make([]C.PmEvent, size) for i, evt := range events { var event C.PmEvent event.timestamp = C.PmTimestamp(evt.Timestamp) event.message = C.PmMessage((((evt.Data2 << 16) & 0xFF0000) | ((evt.Data1 << 8) & 0xFF00) | (evt.Status & 0xFF))) buffer[i] = event } return convertToError(C.Pm_Write(unsafe.Pointer(s.pmStream), &buffer[0], C.int32_t(size))) }
// WriteSysExBytes writes a system exclusive MIDI message given as a []byte to the output stream. func (s *Stream) WriteSysExBytes(when Timestamp, msg []byte) error { return convertToError(C.Pm_WriteSysEx(unsafe.Pointer(s.pmStream), C.PmTimestamp(when), (*C.uchar)(unsafe.Pointer(&msg[0])))) }
// Writes a system exclusive MIDI message to the output stream. func (s *Stream) WriteSysEx(when Timestamp, msg string) error { return convertToError(C.Pm_WriteSysEx(unsafe.Pointer(s.pmStream), C.PmTimestamp(when), nil)) }