{"id":2489,"date":"2023-02-04T21:57:24","date_gmt":"2023-02-04T12:57:24","guid":{"rendered":"http:\/\/oreoreki.gotdns.ch\/?p=2489"},"modified":"2023-02-04T23:50:50","modified_gmt":"2023-02-04T14:50:50","slug":"post-2489","status":"publish","type":"post","link":"http:\/\/oreoreki.gotdns.ch\/?p=2489","title":{"rendered":"[VBA MIDI]\u300c\u30b7\u30e7\u30c3\u30af\u3092\u53d7\u3051\u305f\u6642\u300d\u306b\u6d41\u308c\u308b\u30af\u30e9\u30b7\u30c3\u30af\u66f2"},"content":{"rendered":"<p>https:\/\/youtube.com\/shorts\/V8TplznoaV0<\/p>\n<p><span>\u300c\u30b7\u30e7\u30c3\u30af\u3092\u53d7\u3051\u305f\u6642\u300d\u306b<br \/>\n\u6d41\u308c\u308b\u30af\u30e9\u30b7\u30c3\u30af\u66f2<br \/>\nIn &#8220;Shocked&#8221;<br \/>\nflowing classical music<\/p>\n<p>\u30d9\u30fc\u30c8\u30d9\u30f3\uff1a\u904b\u547d\/Symphony No. 5 (Beethoven)<br \/>\n\u30d0\u30c3\u30cf\uff1a\u30c8\u30c3\u30ab\u30fc\u30bf\u3068\u30d5\u30fc\u30ac\/Toccata and Fugue(Bach)<br \/>\n\u30b5\u30e9\u30b5\u30fc\u30c6\uff1a\u30c4\u30a3\u30b4\u30a4\u30cd\u30eb\u30ef\u30a4\u30bc\u30f3\/Zigeunerweisen(Sarasate)<br \/>\n\u30b0\u30ea\u30fc\u30b0\uff1a\u30d4\u30a2\u30ce\u5354\u594f\u66f2\/Piano Concerto (Grieg)<br \/>\n\u30b7\u30e5\u30fc\u30de\u30f3\uff1a\u30d4\u30a2\u30ce\u5354\u594f\u66f2\/Piano Concerto (Schumann)<\/span><br \/>\n<span class=\"bold-red\">\u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindows11\/Office2016\u3067\u4f5c\u6210\u3057\u3066\u307e\u3059\u3002<br \/>\n<\/span><\/p>\n<h2><\/h2>\n<pre class=\"prism line-numbers lang-ts\" data-lang=\"TypeScript\"><code>'MIDI API\r\nPrivate Declare PtrSafe Function midiOutGetNumDevs Lib \"winmm\" () As Integer\r\nPrivate Declare PtrSafe Function midiOutOpen Lib \"winmm.dll\" (lphMidiOut As LongPtr, ByVal uDeviceID As Long, ByVal dwCallback As LongPtr, ByVal dwInstance As LongPtr, ByVal dwflags As Long) As Long\r\nPrivate Declare PtrSafe Function midiOutShortMsg Lib \"winmm.dll\" (ByVal hMidiOut As LongPtr, ByVal dwMsg As Long) As Long\r\nPrivate Declare PtrSafe Function midiOutClose Lib \"winmm.dll\" (ByVal hMidiOut As LongPtr) As Long\r\nDim Handle As LongPtr\r\n'Sleep API\r\nPrivate Declare PtrSafe Sub Sleep Lib \"kernel32\" (ByVal dwMilliseconds As LongPtr)\r\nPrivate Declare PtrSafe Function MessageBoxTimeoutA Lib \"User32.dll\" (ByVal hWnd As LongPtr, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As VbMsgBoxStyle, ByVal wLanguageID As Long, ByVal dwMilliseconds As Long) As Long\r\nSub test11()\r\n    MessageBoxTimeoutA 0, \"\u30d9\u30fc\u30c8\u30d9\u30f3\uff1a\u904b\u547d\/Symphony No. 5 (Beethoven)\", \"\u97f3\", 0, 65536, 3000\r\n    Call PlayMsg2(\"00C0,FF0010,1F:2B:37:43,,,,1F:2B:37:43,,,,1F:2B:37:43,,,,1B:27:33:3F,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1D:29:35:41,,,,35:41,1D:29,,,,1D:29:35:41,,,,1A:26:32:3E,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\")\r\n\r\n    MessageBoxTimeoutA 0, \"\u30d0\u30c3\u30cf\uff1a\u30c8\u30c3\u30ab\u30fc\u30bf\u3068\u30d5\u30fc\u30ac\/Toccata and Fugue(Bach)\", \"\u97f3\", 0, 65536, 3000\r\n    Call PlayMsg2(\"10C0,FF0010,45:51,,,,7F4580,7F5180,43:4F,,7F4380,7F4F80,45:51,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7F4580,7F5180,,,,,,,,,,,,,,,,43:4F,,,,7F4380,7F4F80,41:4D,,,,,7F4180,7F4D80,40:4C,,,,,7F4080,7F4C80,3E:4A,,,,7F3E80,7F4A80,3D:49,,,,,,,,,,,,,,,,,,,,,7F3D80,7F4980,,3E:4A,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7F3E80,7F4A80,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,39:45,,,,7F3980,7F4580,37:43,,7F3780,7F4380,39:45,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7F3980,7F4580,,,,,,,,,,,,34:40,,,,,,,,,,7F3480,7F4080,35:41,,,,,,,,,,,7F3580,7F4180,31:3D,,,,,,,,,,7F3180,7F3D80,32:3E,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7F3280,7F3E80,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\")\r\n\r\n    MessageBoxTimeoutA 0, \"\u30b5\u30e9\u30b5\u30fc\u30c6\uff1a\u30c4\u30a3\u30b4\u30a4\u30cd\u30eb\u30ef\u30a4\u30bc\u30f3\/Zigeunerweisen(Sarasate)\", \"\u97f3\", 0, 65536, 3000\r\n    Call PlayMsg2(\"00C0,FF0015,1F:2B:43,,,,,,,,,,,,,,,,,24:30:48,,,,,,,,,,,,,,,,,26:32:4A,,,,,,,,,,,,,,,,,24:2B:30:3F:4B,,,,,,,,,,,,,,,,,,,2B:30:3C:3F,,,30:43,,2B:3C:3F,,,30:43,,,2B:30:3C:3F,,,30:43,,2B:3C:3F,,,30:43,,,2B:3C:3F,,,2B:30:43,,,2B:30:3C:3F,,,,,30:43,,,,,,4A,29:2C:32:3E,,,,,,,,,,,,,,,,,,,,,,,,,24:48,,26,4A,,27:4B,,26:4A,,,24:2C:30:3C:48,,,,,,,,,,,,,,,,,,,,23:2F:3B:47,,,,,,,,,24:30:3C:48,,,,,,,,,,,,,,,,,,,,2B:3C:3F,,30:43,,,2B:3C:3F,,,30:43,,,2B:3C:3F,,30:43,,,2B:3C:3F,,,30:43,,2B:3C,3F,,30:43,,,2B:3C:3F,,,,30:43,,,,37:3C:3F,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\")\r\n\r\n    MessageBoxTimeoutA 0, \"\u30b0\u30ea\u30fc\u30b0\uff1a\u30d4\u30a2\u30ce\u5354\u594f\u66f2\/Piano Concerto (Grieg)\", \"\u97f3\", 0, 65536, 3000\r\n    Call PlayMsg2(\"00C0,FF0015,51:54:58:5D,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,45:51:5D,,,,,,5C:68,44:50,,,,,,40:44:47:4C:58:5C:5F:64,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,40:4C:58:64,,,,,,3C:48:54:60,,,,,,,39:3C:40:45:51:54:58:5D,,,,,,,,,,39:45:51:5D,,,,,38:44:50:5C,,,,,,34:38:3B:40:4C:50:53:58,,,,,,,,,,34:40:4C:58,,,,,30:3C:48:4C:54,,,,,,,2D:30:34:39:45:48:4C:51,,,,,,,,,,,2D:39:45:51,,,,,,,2C:38:44:50,,,,,,,28:2F:34:40:44:47:4C,,,,,,,,,,,,28:34:40:44:4C,,,,,,,,24:30:3C:48,,,,,,,,,,,21:2D:39:45,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\")\r\n\r\n    MessageBoxTimeoutA 0, \"\u30b7\u30e5\u30fc\u30de\u30f3\uff1a\u30d4\u30a2\u30ce\u5354\u594f\u66f2\/Piano Concerto (Schumann)\", \"\u97f3\", 0, 65536, 3000\r\n    Call PlayMsg2(\"00C0,FF0010,28:34:44:47:4C,,,,,,,,,,44:48:4C:50:54:58,,,45:48:4D:51:54:59,,,,,,,,,,,,,,,,39:40:45:49:4C:51:55,,,41:45:4A:4D:56,,,,,,,,3D:41:45:49:4D:51:55,,3A:3E:41:46:4A:4D:52,,,,,,,3B:40:44:47:4C:50,,,3C:40:45:48:4C:51,,,,,,,38:3C:40:44:48:4C,,,39:3C:41:45:48:4D,,,,,,,34:39:3D:40:45:49,,,35:39:41:45:4A,,,,,,,31:35:39:3D:45,,32:35:3A:3E:46,,,,,,,,2F:34:38:3B:40:44,,,30:34:39:40:45,,,,,,,,26:32:39:3E:41,,,28:30:34:39:3C:40,,,,,,,,,,,,,28:34:44:47:4A:4C:50,,,,,,,,,,,,,,,,21:2D:34:3C:45:48:4C:51,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\")\r\nEnd Sub\r\nPublic Function PlayMsg2(msg_dat)\r\n    Dim Msg As Long\r\n    'MIDI\u51fa\u529b\u30c7\u30d0\u30a4\u30b9\u53d6\u5f97\r\n    Dim Ret As Long\r\n    Ret = midiOutGetNumDevs\r\n    'MIDI\u30c7\u30d0\u30a4\u30b9\u3092\u958b\u304f\r\n    If Ret = 0 Then\r\n        Debug.Print \"MIDI\u97f3\u6e90\u304c\u7121\u3044\u305f\u3081\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002\"\r\n        Exit Function\r\n    End If\r\n    Ret = midiOutOpen(Handle, -1, 0, 0, 0)\r\n    arr_dat = Split(msg_dat, \",\")\r\n    Call midiOutShortMsg(Handle, \"&H\" & Mid(arr_dat(0), 1, 2) & \"C0\")\r\n    sleep_time = 50\r\n    For i = 0 To UBound(arr_dat)\r\n        If Len(arr_dat(i)) Then\r\n            If InStr(arr_dat(i), \":\") + (Sgn(Len(arr_dat(i)) - 2) - 1) Then\r\n                If Len(arr_dat(i)) Then\r\n                    arr_dat2 = Split(arr_dat(i), \":\")\r\n                    For j = 0 To UBound(arr_dat2)\r\n                        Msg = Val(\"&H7F\" & arr_dat2(j) & \"90\")\r\n                        'Debug.Print Hex(Msg)\r\n                        Call midiOutShortMsg(Handle, Msg)\r\n                    Next\r\n                End If\r\n                Sleep (sleep_time)\r\n            Else\r\n                If Mid(arr_dat(i), 1, 2) = \"FF\" Then\r\n                    sleep_time = Val(\"&H\" + Mid(arr_dat(i), 3))\r\n                Else\r\n                    Call midiOutShortMsg(Handle, \"&H\" & arr_dat(i))\r\n                End If\r\n            End If\r\n        Else\r\n                Sleep (sleep_time)\r\n        End If\r\n        DoEvents\r\n    Next\r\n    'MIDI\u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u308b\r\n    Ret = midiOutClose(Handle)\r\nEnd Function\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/youtube.com\/shorts\/V8TplznoaV0 \u300c\u30b7\u30e7\u30c3\u30af\u3092\u53d7\u3051\u305f\u6642\u300d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2492,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[],"class_list":["post-2489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vba"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/oreoreki.gotdns.ch\/wp-content\/uploads\/sites\/2\/2023\/02\/vba-midi.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9WqRX-E9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2489"}],"version-history":[{"count":5,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2489\/revisions"}],"predecessor-version":[{"id":2497,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2489\/revisions\/2497"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/media\/2492"}],"wp:attachment":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2489"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}