예제 #1
0
파일: midi.go 프로젝트: boynton/midi-ell
func findMidiOutputDevice(name string) (portmidi.DeviceId, string) {
	devcount := portmidi.CountDevices()
	for i := 0; i < devcount; i++ {
		id := portmidi.DeviceId(i)
		info := portmidi.GetDeviceInfo(id)
		if info.IsOutputAvailable {
			if info.Name == name {
				return id, info.Name
			}
		}
	}
	id := portmidi.GetDefaultOutputDeviceId()
	info := portmidi.GetDeviceInfo(id)
	return id, info.Name
}
예제 #2
0
파일: gen.go 프로젝트: mdwhatcott/gen
func listDevices() {
	n := portmidi.CountDevices()
	for i := 0; i < n; i++ {
		info := portmidi.GetDeviceInfo(portmidi.DeviceId(i))
		fmt.Printf("Device %d: %v\n", i, info)
	}
}
예제 #3
0
func newDevices() (devs devices) {
	portmidi.Initialize()
	devs = devices{
		info: map[portmidi.DeviceId]*portmidi.DeviceInfo{},
	}

	for id := 0; id < portmidi.CountDevices(); id++ {
		devID := deviceID(id)
		devs.info[devID] = portmidi.GetDeviceInfo(devID)
	}
	return
}
예제 #4
0
func getDeviceId() (portmidi.DeviceId, error) {
	total := portmidi.CountDevices()

	for id := 0; id < total; id++ {
		id := portmidi.DeviceId(id)
		info := portmidi.GetDeviceInfo(id)
		if info.Name == "MicroBrute" && info.IsOutputAvailable {
			return id, nil
		}
	}

	return -1, fmt.Errorf("MicroBrute not found")
}
예제 #5
0
파일: midi.go 프로젝트: boynton/midi-ell
func findMidiInputDevice(name string) portmidi.DeviceId {
	devcount := portmidi.CountDevices()
	for i := 0; i < devcount; i++ {
		id := portmidi.DeviceId(i)
		info := portmidi.GetDeviceInfo(id)
		if info.IsInputAvailable {
			if info.Name == name {
				return id
			}
		}
	}
	return portmidi.DeviceId(-1)
}
예제 #6
0
// discovers the currently connected LaunchControl device
// as a MIDI device.
func discover() (input portmidi.DeviceId, output portmidi.DeviceId, err error) {
	in := -1
	out := -1
	for i := 0; i < portmidi.CountDevices(); i++ {
		info := portmidi.GetDeviceInfo(portmidi.DeviceId(i))
		if strings.Contains(info.Name, "Launch Control XL") {
			if info.IsInputAvailable {
				in = i
			}
			if info.IsOutputAvailable {
				out = i
			}
		}
	}
	if in == -1 || out == -1 {
		err = errors.New("launchcontrol: no launch control is connected")
	} else {
		input = portmidi.DeviceId(in)
		output = portmidi.DeviceId(out)
	}
	return
}