Beispiel #1
0
func NewSource(client Client, name string) (source Source, err error) {
	var endpointRef C.MIDIEndpointRef

	stringToCFString(name, func(cfName C.CFStringRef) {
		osStatus := C.MIDISourceCreate(client.client, cfName, &endpointRef)

		if osStatus != C.noErr {
			err = errors.New(fmt.Sprintf("%d: failed to create a source", int(osStatus)))
		} else {
			source = Source{endpointRef, &Object{C.MIDIObjectRef(endpointRef)}}
		}
	})

	return
}
Beispiel #2
0
func (entity Entity) Destinations() (destinations []Destination, err error) {
	numberOfDestinations := int(C.ItemCount(C.MIDIEntityGetNumberOfDestinations(entity.entity)))
	destinations = make([]Destination, numberOfDestinations)

	for i := range destinations {
		destination := C.MIDIEntityGetDestination(entity.entity, 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
}
Beispiel #3
0
func (device Device) Entities() (entities []Entity, err error) {
	numberOfEntitiles := int(C.ItemCount(C.MIDIDeviceGetNumberOfEntities(device.device)))
	entities = make([]Entity, numberOfEntitiles)

	for i := range entities {
		entity := C.MIDIDeviceGetEntity(device.device, C.ItemCount(i))

		if entity == (C.MIDIEntityRef)(0) {
			err = errors.New("failed to get entity")

			return
		}

		entities[i] = Entity{entity, &Object{C.MIDIObjectRef(entity)}}
	}

	return
}
Beispiel #4
0
func (entity Entity) Sources() (sources []Source, err error) {
	numberOfSources := int(C.ItemCount(C.MIDIEntityGetNumberOfSources(entity.entity)))
	sources = make([]Source, numberOfSources)

	for i := range sources {
		source := C.MIDIEntityGetSource(entity.entity, C.ItemCount(i))

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

			return
		}

		sources[i] = Source{source, &Object{C.MIDIObjectRef(source)}}
	}

	return
}
Beispiel #5
0
func AllDevices() (devices []Device, err error) {
	numberOfDevices := numberOfDevices()
	devices = make([]Device, numberOfDevices)

	for i := range devices {
		device := C.MIDIGetDevice(C.ItemCount(i))

		if device == (C.MIDIDeviceRef)(0) {
			err = errors.New("failed to get device")

			return
		}

		devices[i] = Device{
			device,
			&Object{C.MIDIObjectRef(device)}}
	}

	return
}