Пример #1
0
func (packet Packet) Send(port *OutputPort, destination *Destination) (err error) {
	osStatus := C.MIDISend(port.port, destination.endpoint, &packet.packetList)

	if osStatus != C.noErr {
		err = errors.New(fmt.Sprintf("%d: failed to send MIDI", int(osStatus)))
	}

	return
}
Пример #2
0
func handleNoteEvent(n NoteEvent, output Output) {
	var packetList C.MIDIPacketList
	if n.On {
		packetList = C.MidiNoteOn((C.int)(n.Note), (C.int)(output.midiChannel), (C.int)(n.Velocity))
	} else {
		packetList = C.MidiNoteOff((C.int)(n.Note), (C.int)(output.midiChannel), (C.int)(0))
	}

	C.MIDISend(output.cmPort, output.destination, &packetList)
}