オープンソースのフレームワーク「MIKMIDI」を用いてMIDIデバイス情報を取得するAppleScriptです。
Objective-Cのプログラムもいろいろ読んできましたが、その中でもこれは難易度が高く、高尚であるために読んでもさっぱりわかりません。
–> Download MIKMIDI.framework(To ~/Library/Frameworks/)
AppleScript名:MIKMIDIでデバイス一覧を取得 v2 |
— Created 2015-11-13 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "MIKMIDI" –https://github.com/mixedinkey-opensource/MIKMIDI property midiDeviceManager : missing value set midiDeviceManager to current application’s MIKMIDIDeviceManager’s sharedDeviceManager()’s availableDevices() set aRes to midiDeviceManager’s mutableCopy() set endpointsInDevs to current application’s NSMutableSet’s |set|() repeat with i in (midiDeviceManager as list) set aSrcList to (current application’s NSSet’s setWithArray:(i’s entities()’s valueForKeyPath:"sources")) set aDstList to (current application’s NSSet’s setWithArray:(i’s entities()’s valueForKeyPath:"destinations")) (endpointsInDevs’s unionSet:aSrcList) (endpointsInDevs’s unionSet:aDstList) end repeat endpointsInDevs’s |description|() –> (NSSet) {{(MIKMIDISourceEndpoint) <MIKMIDISourceEndpoint: 0x7f8a61d47950> 新しい外部装置}, {(MIKMIDISourceEndpoint) <MIKMIDISourceEndpoint: 0x7f8a63a65610> IAC Driver GarageBand}, {(MIKMIDIDestinationEndpoint) <MIKMIDIDestinationEndpoint: 0x7f8a61bbc130> IAC Driver GarageBand}, {(MIKMIDIDestinationEndpoint) <MIKMIDIDestinationEndpoint: 0x7f8a5ecadcf0> 新しい外部装置}} –midiDeviceManager’s virtualSources() –Real MIDI I/Fがつながっていないとエラーになる –set devicelessSources to current application’s NSMutableSet’s setWithWrray:(midiDeviceManager’s virtualSources()) |