(bind-func pm_print_devices
(lambda ()
(let ((ndev (Pm_CountDevices)))
(if (= ndev 0)
(println "No MIDI devices found")
(begin
(println "\n-- MIDI input devices --\n")
(doloop (i ndev)
(if (= (tref (Pm_GetDeviceInfo i) 3) 1)
(println " device id" i ":" (Pm_GetDeviceInfo i))))
(println "\n-- MIDI output devices --\n")
(doloop (i ndev)
(if (= (tref (Pm_GetDeviceInfo i) 4) 1)
(println " device id" i ":" (Pm_GetDeviceInfo i)))))))))