ホーム › Media.Audio › midiOutShortMsg
midiOutShortMsg
関数MIDIショートメッセージを出力デバイスへ送信する。
シグネチャ
// WINMM.dll
#include <windows.h>
DWORD midiOutShortMsg(
HMIDIOUT hmo,
DWORD dwMsg
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hmo | HMIDIOUT | in | MIDI 出力デバイスのハンドル。このパラメーターには、HMIDIOUT にキャストした MIDI ストリームのハンドルを指定することもできます。 | ||||||||||||||||||||||||||||||
| dwMsg | DWORD | in | MIDI メッセージ。メッセージは DWORD 値にパックされ、メッセージの最初のバイトが下位バイトに格納されます。メッセージは次のようにこのパラメーターにパックされます。
2 つの MIDI データバイトは、MIDI ステータスバイトに応じて省略可能です。一連のメッセージが同じステータスバイトを持つ場合、その系列の最初のメッセージ以降ではステータスバイトを省略でき、ランニングステータスを構成します。ランニングステータス用のメッセージは次のようにパックします。
|
戻り値の型: DWORD
公式ドキュメント
midiOutShortMsg 関数は、指定された MIDI 出力デバイスに短い MIDI メッセージを送信します。
戻り値
成功した場合は MMSYSERR_NOERROR を返し、それ以外の場合はエラーを返します。発生し得るエラー値には次のものがあります。
| 戻り値 | 説明 |
|---|---|
| アプリケーションが、ステータスバイトを含まないメッセージをストリームハンドルに送信しました。 | |
| ハードウェアが他のデータの処理でビジー状態です。 | |
| 指定されたデバイスハンドルが無効です。 |
解説(Remarks)
この関数は、システムエクスクルーシブメッセージおよびストリームメッセージを除く任意の MIDI メッセージを送信するために使用します。
この関数は、メッセージが出力デバイスに送信されるまで戻らない場合があります。同じデバイスでストリームを再生している間でも短いメッセージを送信できます(ただし、この場合はランニングステータスを使用できません)。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WINMM.dll
#include <windows.h>
DWORD midiOutShortMsg(
HMIDIOUT hmo,
DWORD dwMsg
);[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint midiOutShortMsg(
IntPtr hmo, // HMIDIOUT
uint dwMsg // DWORD
);<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function midiOutShortMsg(
hmo As IntPtr, ' HMIDIOUT
dwMsg As UInteger ' DWORD
) As UInteger
End Function' hmo : HMIDIOUT
' dwMsg : DWORD
Declare PtrSafe Function midiOutShortMsg Lib "winmm" ( _
ByVal hmo As LongPtr, _
ByVal dwMsg As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
midiOutShortMsg = ctypes.windll.winmm.midiOutShortMsg
midiOutShortMsg.restype = wintypes.DWORD
midiOutShortMsg.argtypes = [
wintypes.HANDLE, # hmo : HMIDIOUT
wintypes.DWORD, # dwMsg : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
midiOutShortMsg = Fiddle::Function.new(
lib['midiOutShortMsg'],
[
Fiddle::TYPE_VOIDP, # hmo : HMIDIOUT
-Fiddle::TYPE_INT, # dwMsg : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "winmm")]
extern "system" {
fn midiOutShortMsg(
hmo: *mut core::ffi::c_void, // HMIDIOUT
dwMsg: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINMM.dll")]
public static extern uint midiOutShortMsg(IntPtr hmo, uint dwMsg);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_midiOutShortMsg' -Namespace Win32 -PassThru
# $api::midiOutShortMsg(hmo, dwMsg)#uselib "WINMM.dll"
#func global midiOutShortMsg "midiOutShortMsg" sptr, sptr
; midiOutShortMsg hmo, dwMsg ; 戻り値は stat
; hmo : HMIDIOUT -> "sptr"
; dwMsg : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WINMM.dll"
#cfunc global midiOutShortMsg "midiOutShortMsg" sptr, int
; res = midiOutShortMsg(hmo, dwMsg)
; hmo : HMIDIOUT -> "sptr"
; dwMsg : DWORD -> "int"; DWORD midiOutShortMsg(HMIDIOUT hmo, DWORD dwMsg)
#uselib "WINMM.dll"
#cfunc global midiOutShortMsg "midiOutShortMsg" intptr, int
; res = midiOutShortMsg(hmo, dwMsg)
; hmo : HMIDIOUT -> "intptr"
; dwMsg : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procmidiOutShortMsg = winmm.NewProc("midiOutShortMsg")
)
// hmo (HMIDIOUT), dwMsg (DWORD)
r1, _, err := procmidiOutShortMsg.Call(
uintptr(hmo),
uintptr(dwMsg),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction midiOutShortMsg(
hmo: THandle; // HMIDIOUT
dwMsg: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'midiOutShortMsg';result := DllCall("WINMM\midiOutShortMsg"
, "Ptr", hmo ; HMIDIOUT
, "UInt", dwMsg ; DWORD
, "UInt") ; return: DWORD●midiOutShortMsg(hmo, dwMsg) = DLL("WINMM.dll", "dword midiOutShortMsg(void*, dword)")
# 呼び出し: midiOutShortMsg(hmo, dwMsg)
# hmo : HMIDIOUT -> "void*"
# dwMsg : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winmm" fn midiOutShortMsg(
hmo: ?*anyopaque, // HMIDIOUT
dwMsg: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc midiOutShortMsg(
hmo: pointer, # HMIDIOUT
dwMsg: uint32 # DWORD
): uint32 {.importc: "midiOutShortMsg", stdcall, dynlib: "WINMM.dll".}pragma(lib, "winmm");
extern(Windows)
uint midiOutShortMsg(
void* hmo, // HMIDIOUT
uint dwMsg // DWORD
);ccall((:midiOutShortMsg, "WINMM.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32),
hmo, dwMsg)
# hmo : HMIDIOUT -> Ptr{Cvoid}
# dwMsg : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t midiOutShortMsg(
void* hmo,
uint32_t dwMsg);
]]
local winmm = ffi.load("winmm")
-- winmm.midiOutShortMsg(hmo, dwMsg)
-- hmo : HMIDIOUT
-- dwMsg : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINMM.dll');
const midiOutShortMsg = lib.func('__stdcall', 'midiOutShortMsg', 'uint32_t', ['void *', 'uint32_t']);
// midiOutShortMsg(hmo, dwMsg)
// hmo : HMIDIOUT -> 'void *'
// dwMsg : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINMM.dll", {
midiOutShortMsg: { parameters: ["pointer", "u32"], result: "u32" },
});
// lib.symbols.midiOutShortMsg(hmo, dwMsg)
// hmo : HMIDIOUT -> "pointer"
// dwMsg : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t midiOutShortMsg(
void* hmo,
uint32_t dwMsg);
C, "WINMM.dll");
// $ffi->midiOutShortMsg(hmo, dwMsg);
// hmo : HMIDIOUT
// dwMsg : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Winmm extends StdCallLibrary {
Winmm INSTANCE = Native.load("winmm", Winmm.class);
int midiOutShortMsg(
Pointer hmo, // HMIDIOUT
int dwMsg // DWORD
);
}@[Link("winmm")]
lib LibWINMM
fun midiOutShortMsg = midiOutShortMsg(
hmo : Void*, # HMIDIOUT
dwMsg : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef midiOutShortMsgNative = Uint32 Function(Pointer<Void>, Uint32);
typedef midiOutShortMsgDart = int Function(Pointer<Void>, int);
final midiOutShortMsg = DynamicLibrary.open('WINMM.dll')
.lookupFunction<midiOutShortMsgNative, midiOutShortMsgDart>('midiOutShortMsg');
// hmo : HMIDIOUT -> Pointer<Void>
// dwMsg : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function midiOutShortMsg(
hmo: THandle; // HMIDIOUT
dwMsg: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'midiOutShortMsg';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "midiOutShortMsg"
c_midiOutShortMsg :: Ptr () -> Word32 -> IO Word32
-- hmo : HMIDIOUT -> Ptr ()
-- dwMsg : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let midioutshortmsg =
foreign "midiOutShortMsg"
((ptr void) @-> uint32_t @-> returning uint32_t)
(* hmo : HMIDIOUT -> (ptr void) *)
(* dwMsg : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winmm (t "WINMM.dll"))
(cffi:use-foreign-library winmm)
(cffi:defcfun ("midiOutShortMsg" midi-out-short-msg :convention :stdcall) :uint32
(hmo :pointer) ; HMIDIOUT
(dw-msg :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $midiOutShortMsg = Win32::API::More->new('WINMM',
'DWORD midiOutShortMsg(HANDLE hmo, DWORD dwMsg)');
# my $ret = $midiOutShortMsg->Call($hmo, $dwMsg);
# hmo : HMIDIOUT -> HANDLE
# dwMsg : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。