コード例 #1
0
ファイル: destinations.go プロジェクト: j14159/gocmc
func GetDestinations() (ret map[string]Destination) {
	destCount := C.MIDIGetNumberOfDestinations()
	fmt.Println("Found destination count:  ", destCount)

	ret = make(map[string]Destination)
	var x C.ItemCount = 0
	for ; x < destCount; x++ {
		dest := C.MIDIGetDestination(x)
		var destName C.CFStringRef
		C.MIDIObjectGetStringProperty((C.MIDIObjectRef)(dest), C.kMIDIPropertyName, &destName)
		cleanName := strings.Trim(cstrToStr(destName), "\u0000")
		ret[cleanName] = Destination{cleanName, CoreMidiEndpoint(dest)}
	}

	return
}
コード例 #2
0
ファイル: destination.go プロジェクト: roger2000/go-coremidi
func AllDestinations() (destinations []Destination, err error) {
	numberOfDestinations := numberOfDestinations()
	destinations = make([]Destination, numberOfDestinations)

	for i := range destinations {
		destination := C.MIDIGetDestination(C.ItemCount(i))

		if destination == (C.MIDIEndpointRef)(0) {
			err = errors.New("failed to get destination")

			return
		}

		destinations[i] = Destination{
			destination,
			&Object{C.MIDIObjectRef(destination)}}
	}

	return
}