{"id":814,"date":"2010-09-18T00:00:00","date_gmt":"2010-09-17T15:00:00","guid":{"rendered":"http:\/\/localhost\/blog\/?p=800"},"modified":"2014-08-14T11:32:29","modified_gmt":"2014-08-14T02:32:29","slug":"midi%e3%82%ad%e3%83%bc%e3%83%9c%e3%83%bc%e3%83%89%e5%85%a5%e5%8a%9b%e3%82%a2%e3%83%97%e3%83%aa%e3%81%8c%e3%81%a7%e3%81%8d%e3%81%9f","status":"publish","type":"post","link":"https:\/\/denasu.com\/blog\/2010\/09\/diary814","title":{"rendered":"MIDI\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u30a2\u30d7\u30ea\u304c\u3067\u304d\u305f"},"content":{"rendered":"<p>C#\u3067MIDI\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u3092\u3084\u3063\u3066\u307f\u308b\u3002midiInOpen\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u767b\u9332\u3057\u3066\u304a\u3051\u3070\uff0cmidiInStart\/midiInStop\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u3051\u53d6\u308c\u308b\u3002<\/p>\n<pre class=\"brush:csharp\">\r\n{\r\n    [DllImport(\"winmm.dll\")]\r\n    public static extern uint midiOutOpen(\r\n        ref IntPtr phmo,\r\n        uint uDeviceID,\r\n        IntPtr dwCallback,\r\n        IntPtr dwInstance,\r\n        uint fdwOpen);\r\n\r\n    public delegate void CallBackDelegate(\r\n        IntPtr hdrvr,\r\n        uint uMsg,\r\n        uint dwUser,\r\n        uint dw1,\r\n        uint dw2);\r\n}\r\n\r\npublic class MIDIIn\r\n{\r\n    private Win32MIDI.CallBackDelegate _callback = null;\r\n\r\n    public void Open()\r\n    {\r\n        _callback = new Win32MIDI.CallBackDelegate(CallBack);\r\n\r\n        Win32MIDI.midiInOpen(\r\n            ref _midiin,\r\n            _mididevice,\r\n            (IntPtr)Marshal.GetFunctionPointerForDelegate(_callback),\r\n            (IntPtr)0,\r\n            Win32MIDI.CALLBACK_FUNCTION);\r\n    }\r\n\r\n    private void CallBack(IntPtr hdrvr, uint uMsg, uint dwUser, uint dw1, uint dw2)\r\n    {\r\n        int state = (int)dw1 & 0xff;\r\n        int data1 = (int)dw1 >> 8 & 0xff;\r\n        int data2 = (int)dw1 >> 16 & 0xff;\r\n    }\r\n}\r\n<\/pre>\n<p>\u6700\u521d\uff0cC++\u3067\u5b9f\u88c5\u3059\u308b\u3068\u304d\u3068\u540c\u3058\u3088\u3046\u306bCallBack\u3092static\u30e1\u30bd\u30c3\u30c9\u306b\u3057\u3066\u3044\u305f\u306e\u3060\u304c\uff0c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30f3\u30d0\u5909\u6570\u3092\u4f7f\u3044\u305f\u304f\u3066\uff0cmidiInOpen\u306edwInstance\u306bthis\u3092\u6e21\u3059\u3053\u3068\u3092\u8003\u3048\u3066\u3044\u305f\u3002\u3067\u3082this\u3092IntPtr\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3068\u3044\u3046\u304b\u5909\u63db\u3057\u3066\u3044\u3044\u306e\u304b\u3092\u8abf\u3079\u3066\u3082\u4f55\u3082\u60c5\u5831\u306f\u898b\u3064\u304b\u3089\u306a\u3044\u3002\u6700\u7d42\u7684\u306b\u300cGetFunctionPointerForDelegate\u306fthis\u30dd\u30a4\u30f3\u30bf\u3092\u3046\u307e\u3044\u3053\u3068\u6271\u3063\u3066\u304f\u308c\u308b\u300d\u3068\u3044\u3046\u3088\u3046\u306a\u8a18\u8ff0\u3092\u898b\u3064\u3051\u3066\uff0c\u601d\u3044\u304d\u3063\u3066static\u3092\u53d6\u3063\u305f\u3089\u305d\u306e\u307e\u307e\u52d5\u3044\u305f\u3002C++\u306e\u767a\u60f3\u3060\u3068static\u306b\u3057\u306a\u3044\u3068\u52d5\u304b\u306a\u3044\u306e\u3067\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u305d\u306e\u307e\u307e\u6e21\u3059\u3068\u3044\u3046\u306e\u306f\u601d\u3044\u3064\u304d\u3082\u3057\u306a\u304b\u3063\u305f\u3002\u3053\u3093\u306a\u611f\u3058\u3067\u534a\u65e5\u3092\u7121\u99c4\u306b\u3057\u3066\u3057\u307e\u3063\u305f\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u306f\u9806\u8abf\u306b\u9032\u3093\u3067\uff0c\u30ad\u30fc\u30dc\u30fc\u30c9\u7df4\u7fd2\u30bd\u30d5\u30c8\u3063\u307d\u3044\u3082\u306e\u306f\u3067\u304d\u3042\u304c\u3063\u305f\u3002\u305d\u308d\u305d\u308d\u3082\u3070\u3082\u3070\uff08\uff1f\uff09\u306b\u6295\u3052\u3066\u307f\u3088\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#\u3067MIDI\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u3092\u3084\u3063\u3066\u307f\u308b\u3002midiInOpen\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u767b\u9332\u3057\u3066\u304a\u3051\u3070\uff0cmidiInStart\/midiInStop\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u3051\u53d6\u308c\u308b\u3002 { [DllImport(&#8220;winmm.dll&#8221;)] public static extern uint midiOutOpen( ref IntPtr phmo, uint uDeviceID, IntPtr dwCallback, IntPtr dwInstance, uint fdwOpen); public delegate void CallBackDelegate( IntPtr hdrvr, uint uMsg, uint dwUser, uint dw1, uint dw2); } public class MIDIIn { private Win32MIDI.CallBackDelegate _callback = null; public void Open() { _callback = new Win32MIDI.CallBackDelegate(CallBack); Win32MIDI.midiInOpen( ref _midiin, _mididevice, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[7],"class_list":["post-814","post","type-post","status-publish","format-standard","hentry","category-programming","tag-purentro"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4ZThs-d8","_links":{"self":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/comments?post=814"}],"version-history":[{"count":3,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/814\/revisions"}],"predecessor-version":[{"id":2463,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/814\/revisions\/2463"}],"wp:attachment":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/media?parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/categories?post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/tags?post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}