{"id":2466,"date":"2023-01-31T15:07:02","date_gmt":"2023-01-31T06:07:02","guid":{"rendered":"http:\/\/oreoreki.gotdns.ch\/?p=2466"},"modified":"2023-01-31T15:56:38","modified_gmt":"2023-01-31T06:56:38","slug":"post-2466","status":"publish","type":"post","link":"http:\/\/oreoreki.gotdns.ch\/?p=2466","title":{"rendered":"VBA\u3067iphone\u306eopening\u3092\u9cf4\u3089\u3059"},"content":{"rendered":"<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/L0Fw4LChJWs?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=ja&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<p><span>VBA\u3067midi\u3092\u53e9\u3044\u3066iphone\u306eopening\u3092\u9cf4\u3089\u3059\u3002<\/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 \/>\niphone\u306eopening\u3092\u9cf4\u3089\u3059\u306e\u306ftest3\u3067\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\n\r\nSub test1()\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 Sub\r\n    End If\r\n    Ret = midiOutOpen(Handle, -1, 0, 0, 0)\r\n    \r\n    Msg = &H12C0\r\n    Call midiOutShortMsg(Handle, Msg)     ' \u697d\u5668\u3092\u30aa\u30eb\u30ac\u30f3\u306b\u5909\u66f4\r\n    \r\n    Msg = &H7F3C90\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30c9\u3000note on  note=60  Hex\u30673C\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    Msg = &H7F3C80\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30c9\u3000note off note=60  Hex\u30673C\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    Msg = &H7F3E90\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30ec\u3000note on  note=62  Hex\u30673E\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    Msg = &H7F3E80\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30ec\u3000note off note=62  Hex\u30673E\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    Msg = &H7F4090\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30df\u3000note on  note=64  Hex\u306740\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    Msg = &H7F4080\r\n    Call midiOutShortMsg(Handle, Msg)     '\u30df\u3000note off note=64  Hex\u306740\r\n    Sleep (1000) '1\u79d2\u5f85\u3064\r\n    \r\n    'MIDI\u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u308b\r\n    Ret = midiOutClose(Handle)\r\nEnd Sub\r\n\r\nSub test2()\r\n    Dim Msg As Long\r\n    \r\n    'MIDI\u51fa\u529b\u30c7\u30d0\u30a4\u30b9\u53d6\u5f97\r\n    Dim Ret As Long\r\n    Ret = midiOutGetNumDevs\r\n    \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 Sub\r\n    End If\r\n\r\n    Ret = midiOutOpen(Handle, -1, 0, 0, 0)\r\n    gakki = \"\"\r\n    For i = 0 To &H7F\r\n\r\n        Msg = i * 256 + &HC0\r\n        Debug.Print i\r\n        Call midiOutShortMsg(Handle, Msg)     '\r\n        \r\n        Msg = &H7F3C90\r\n        Call midiOutShortMsg(Handle, Msg)     '\u30c9\u3000note=60  Hex\u30673C\r\n        If ExistsSheet(\"\u697d\u5668\u4e00\u89a7\") Then\r\n            MessageBoxTimeoutA 0, i & \"  \" & Sheets(\"\u697d\u5668\u4e00\u89a7\").Cells(i + 1, 2).Value, \"\u697d\u5668\", 0, 65536, 950\r\n        Else\r\n            MessageBoxTimeoutA 0, i & \" \u306e\u97f3\u3067\u3059\", \"\u697d\u5668\", 0, 65536, 950\r\n        End If\r\n        Msg = &H78B0\r\n        Call midiOutShortMsg(Handle, Msg)     '\u30aa\u30fc\u30eb\u30b5\u30a6\u30f3\u30c9\u30aa\u30d5\u3002\u767a\u97f3\u4e2d\u306e\u97f3\u3092\u6b8b\u97ff\u3082\u6d88\u3059\r\n        Sleep (50) '1\u79d2\u5f85\u3064\r\n        DoEvents\r\n    Next\r\n    'MIDI\u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u308b\r\n    Ret = midiOutClose(Handle)\r\nEnd Sub\r\nSub test3()\r\n    'iphone\u306eopening\u3092\u9cf4\u3089\u3059\r\n    Dim Msg As Long\r\n    \r\n    'MIDI\u51fa\u529b\u30c7\u30d0\u30a4\u30b9\u53d6\u5f97\r\n    Dim Ret As Long\r\n    Ret = midiOutGetNumDevs\r\n    \r\n    midi_dat = \"48,46,43,,48,,41,,48,,46,,48,,41,,,,,,,,43,,,,43,,46,,48,,48,46,43,,48,,41,,48,,46,,48,,41,,,,,,,,43,,,,43,,46,,48,\"\r\n\r\n\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 Sub\r\n    End If\r\n\r\n    Ret = midiOutOpen(Handle, -1, 0, 0, 0)\r\n    \r\n    '\u697d\u5668\u3092\u30de\u30ea\u30f3\u30d0\u306b\u3059\u308b\r\n    Msg = &HDC0\r\n    Call midiOutShortMsg(Handle, Msg)\r\n    arr_dat = Split(midi_dat, \",\")\r\n    For j = 0 To 2\r\n        For i = 0 To UBound(arr_dat)\r\n    \r\n            If arr_dat(i) <> \"\" Then\r\n                \r\n                Msg = Val(\"&H7F\" & arr_dat(i) & \"90\")\r\n                Call midiOutShortMsg(Handle, Msg)     '\r\n            End If\r\n    \r\n            Sleep (100) '0.1\u79d2\u5f85\u3064\r\n    \r\n            DoEvents\r\n        Next\r\n    Next\r\n    'MIDI\u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u308b\r\n    Ret = midiOutClose(Handle)\r\nEnd Sub\r\n\r\nPublic Function ExistsSheet(ByVal bookName As String)\r\n    Dim ws As Variant\r\n    For Each ws In Sheets\r\n        If LCase(ws.Name) = LCase(bookName) Then\r\n            ExistsSheet = True ' \u5b58\u5728\u3059\u308b\r\n            Exit Function\r\n        End If\r\n    Next\r\n\r\n    ' \u5b58\u5728\u3057\u306a\u3044\r\n    ExistsSheet = False\r\nEnd Function\r\n\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>VBA\u3067midi\u3092\u53e9\u3044\u3066iphone\u306eopening\u3092\u9cf4\u3089\u3059\u3002 \u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindows11 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2472,"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-2466","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\/01\/mqdefault-2.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9WqRX-DM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2466","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=2466"}],"version-history":[{"count":6,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2466\/revisions"}],"predecessor-version":[{"id":2475,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2466\/revisions\/2475"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/media\/2472"}],"wp:attachment":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}