ホーム › Media.Audio › mixerOpen
mixerOpen
関数オーディオミキサーデバイスを開く。
シグネチャ
// WINMM.dll
#include <windows.h>
DWORD mixerOpen(
HMIXER* phmx, // optional
DWORD uMxId,
UINT_PTR dwCallback, // optional
UINT_PTR dwInstance, // optional
DWORD fdwOpen
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| phmx | HMIXER* | outoptional | 開かれたミキサーデバイスを識別するハンドルを受け取る変数へのポインター。他のオーディオミキサー関数を呼び出す際に、このハンドルを使用してデバイスを識別します。このパラメーターを NULL にすることはできません。 | ||||||||||||||||||||||||||
| uMxId | DWORD | in | 開くミキサーデバイスの識別子。有効なデバイス識別子、または任意の HMIXEROBJ を使用します(ミキサーオブジェクトハンドルの説明については mixerGetID 関数を参照してください)。オーディオミキサーデバイス用の「マッパー」は現在存在しないため、-1 というミキサーデバイス識別子は無効です。 | ||||||||||||||||||||||||||
| dwCallback | UINT_PTR | inoptional | 開こうとしているデバイスに関連付けられたオーディオラインやコントロールの状態が変化したときに呼び出されるウィンドウへのハンドル。コールバックの仕組みを使用しない場合は、このパラメーターに NULL を指定します。 | ||||||||||||||||||||||||||
| dwInstance | UINT_PTR | inoptional | 予約済み。ゼロでなければなりません。 | ||||||||||||||||||||||||||
| fdwOpen | DWORD | in | デバイスを開くためのフラグ。次の値が定義されています。
|
戻り値の型: DWORD
公式ドキュメント
mixerOpen 関数は、指定されたミキサーデバイスを開き、アプリケーションがハンドルを閉じるまでそのデバイスが取り外されないようにします。
戻り値
成功した場合は MMSYSERR_NOERROR を返し、それ以外の場合はエラーを返します。発生する可能性のあるエラー値には次のものがあります。
| 戻り値コード | 説明 |
|---|---|
| 指定されたリソースは、すでに可能な最大数のクライアントによって割り当てられています。 | |
| uMxId パラメーターが無効なデバイス識別子を指定しています。 | |
| 1 つ以上のフラグが無効です。 | |
| uMxId パラメーターが無効なハンドルを指定しています。 | |
| 1 つ以上のパラメーターが無効です。 | |
| uMxId で指定されたオブジェクトに利用できるミキサーデバイスがありません。なお、uMxId が参照する場所にも値 –1 が格納されます。 | |
| リソースを割り当てることができません。 |
解説(Remarks)
システムに存在するオーディオミキサーデバイスの数を調べるには、mixerGetNumDevs 関数を使用します。uMxId で指定するデバイス識別子は、ゼロから、存在するデバイス数より 1 少ない値までの範囲をとります。
コールバック情報を受け取るウィンドウを選択した場合、オーディオラインまたはコントロールの状態が変化したことを示すために、MM_MIXM_LINE_CHANGE および MM_MIXM_CONTROL_CHANGE メッセージがウィンドウプロシージャ関数に送信されます。どちらのメッセージでも、wParam パラメーターはミキサーデバイスのハンドルです。lParam パラメーターは、状態が変化した MM_MIXM_LINE_CHANGE の場合はラインの識別子、MM_MIXM_CONTROL_CHANGE の場合はコントロールの識別子です。
オーディオミキサーのサポートやメディアデバイスを照会するには、mixerGetID 関数を使用します。
64 ビットシステムでは、uMxId パラメーターに 64 ビットの LPHWAVEOUT ポインターを渡す状況において、この関数は期待どおりに動作しない可能性があります。これは uMxId パラメーターが 32 ビットに切り詰められるためです。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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 mixerOpen(
HMIXER* phmx, // optional
DWORD uMxId,
UINT_PTR dwCallback, // optional
UINT_PTR dwInstance, // optional
DWORD fdwOpen
);[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint mixerOpen(
IntPtr phmx, // HMIXER* optional, out
uint uMxId, // DWORD
UIntPtr dwCallback, // UINT_PTR optional
UIntPtr dwInstance, // UINT_PTR optional
uint fdwOpen // DWORD
);<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function mixerOpen(
phmx As IntPtr, ' HMIXER* optional, out
uMxId As UInteger, ' DWORD
dwCallback As UIntPtr, ' UINT_PTR optional
dwInstance As UIntPtr, ' UINT_PTR optional
fdwOpen As UInteger ' DWORD
) As UInteger
End Function' phmx : HMIXER* optional, out
' uMxId : DWORD
' dwCallback : UINT_PTR optional
' dwInstance : UINT_PTR optional
' fdwOpen : DWORD
Declare PtrSafe Function mixerOpen Lib "winmm" ( _
ByVal phmx As LongPtr, _
ByVal uMxId As Long, _
ByVal dwCallback As LongPtr, _
ByVal dwInstance As LongPtr, _
ByVal fdwOpen As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
mixerOpen = ctypes.windll.winmm.mixerOpen
mixerOpen.restype = wintypes.DWORD
mixerOpen.argtypes = [
ctypes.c_void_p, # phmx : HMIXER* optional, out
wintypes.DWORD, # uMxId : DWORD
ctypes.c_size_t, # dwCallback : UINT_PTR optional
ctypes.c_size_t, # dwInstance : UINT_PTR optional
wintypes.DWORD, # fdwOpen : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
mixerOpen = Fiddle::Function.new(
lib['mixerOpen'],
[
Fiddle::TYPE_VOIDP, # phmx : HMIXER* optional, out
-Fiddle::TYPE_INT, # uMxId : DWORD
Fiddle::TYPE_UINTPTR_T, # dwCallback : UINT_PTR optional
Fiddle::TYPE_UINTPTR_T, # dwInstance : UINT_PTR optional
-Fiddle::TYPE_INT, # fdwOpen : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "winmm")]
extern "system" {
fn mixerOpen(
phmx: *mut *mut core::ffi::c_void, // HMIXER* optional, out
uMxId: u32, // DWORD
dwCallback: usize, // UINT_PTR optional
dwInstance: usize, // UINT_PTR optional
fdwOpen: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINMM.dll")]
public static extern uint mixerOpen(IntPtr phmx, uint uMxId, UIntPtr dwCallback, UIntPtr dwInstance, uint fdwOpen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_mixerOpen' -Namespace Win32 -PassThru
# $api::mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)#uselib "WINMM.dll"
#func global mixerOpen "mixerOpen" sptr, sptr, sptr, sptr, sptr
; mixerOpen phmx, uMxId, dwCallback, dwInstance, fdwOpen ; 戻り値は stat
; phmx : HMIXER* optional, out -> "sptr"
; uMxId : DWORD -> "sptr"
; dwCallback : UINT_PTR optional -> "sptr"
; dwInstance : UINT_PTR optional -> "sptr"
; fdwOpen : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WINMM.dll"
#cfunc global mixerOpen "mixerOpen" sptr, int, sptr, sptr, int
; res = mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
; phmx : HMIXER* optional, out -> "sptr"
; uMxId : DWORD -> "int"
; dwCallback : UINT_PTR optional -> "sptr"
; dwInstance : UINT_PTR optional -> "sptr"
; fdwOpen : DWORD -> "int"; DWORD mixerOpen(HMIXER* phmx, DWORD uMxId, UINT_PTR dwCallback, UINT_PTR dwInstance, DWORD fdwOpen)
#uselib "WINMM.dll"
#cfunc global mixerOpen "mixerOpen" intptr, int, intptr, intptr, int
; res = mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
; phmx : HMIXER* optional, out -> "intptr"
; uMxId : DWORD -> "int"
; dwCallback : UINT_PTR optional -> "intptr"
; dwInstance : UINT_PTR optional -> "intptr"
; fdwOpen : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procmixerOpen = winmm.NewProc("mixerOpen")
)
// phmx (HMIXER* optional, out), uMxId (DWORD), dwCallback (UINT_PTR optional), dwInstance (UINT_PTR optional), fdwOpen (DWORD)
r1, _, err := procmixerOpen.Call(
uintptr(phmx),
uintptr(uMxId),
uintptr(dwCallback),
uintptr(dwInstance),
uintptr(fdwOpen),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction mixerOpen(
phmx: Pointer; // HMIXER* optional, out
uMxId: DWORD; // DWORD
dwCallback: NativeUInt; // UINT_PTR optional
dwInstance: NativeUInt; // UINT_PTR optional
fdwOpen: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'mixerOpen';result := DllCall("WINMM\mixerOpen"
, "Ptr", phmx ; HMIXER* optional, out
, "UInt", uMxId ; DWORD
, "UPtr", dwCallback ; UINT_PTR optional
, "UPtr", dwInstance ; UINT_PTR optional
, "UInt", fdwOpen ; DWORD
, "UInt") ; return: DWORD●mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen) = DLL("WINMM.dll", "dword mixerOpen(void*, dword, int, int, dword)")
# 呼び出し: mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
# phmx : HMIXER* optional, out -> "void*"
# uMxId : DWORD -> "dword"
# dwCallback : UINT_PTR optional -> "int"
# dwInstance : UINT_PTR optional -> "int"
# fdwOpen : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winmm" fn mixerOpen(
phmx: ?*anyopaque, // HMIXER* optional, out
uMxId: u32, // DWORD
dwCallback: usize, // UINT_PTR optional
dwInstance: usize, // UINT_PTR optional
fdwOpen: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc mixerOpen(
phmx: pointer, # HMIXER* optional, out
uMxId: uint32, # DWORD
dwCallback: uint, # UINT_PTR optional
dwInstance: uint, # UINT_PTR optional
fdwOpen: uint32 # DWORD
): uint32 {.importc: "mixerOpen", stdcall, dynlib: "WINMM.dll".}pragma(lib, "winmm");
extern(Windows)
uint mixerOpen(
void* phmx, // HMIXER* optional, out
uint uMxId, // DWORD
size_t dwCallback, // UINT_PTR optional
size_t dwInstance, // UINT_PTR optional
uint fdwOpen // DWORD
);ccall((:mixerOpen, "WINMM.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Csize_t, Csize_t, UInt32),
phmx, uMxId, dwCallback, dwInstance, fdwOpen)
# phmx : HMIXER* optional, out -> Ptr{Cvoid}
# uMxId : DWORD -> UInt32
# dwCallback : UINT_PTR optional -> Csize_t
# dwInstance : UINT_PTR optional -> Csize_t
# fdwOpen : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t mixerOpen(
void* phmx,
uint32_t uMxId,
uintptr_t dwCallback,
uintptr_t dwInstance,
uint32_t fdwOpen);
]]
local winmm = ffi.load("winmm")
-- winmm.mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
-- phmx : HMIXER* optional, out
-- uMxId : DWORD
-- dwCallback : UINT_PTR optional
-- dwInstance : UINT_PTR optional
-- fdwOpen : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINMM.dll');
const mixerOpen = lib.func('__stdcall', 'mixerOpen', 'uint32_t', ['void *', 'uint32_t', 'uintptr_t', 'uintptr_t', 'uint32_t']);
// mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
// phmx : HMIXER* optional, out -> 'void *'
// uMxId : DWORD -> 'uint32_t'
// dwCallback : UINT_PTR optional -> 'uintptr_t'
// dwInstance : UINT_PTR optional -> 'uintptr_t'
// fdwOpen : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINMM.dll", {
mixerOpen: { parameters: ["pointer", "u32", "usize", "usize", "u32"], result: "u32" },
});
// lib.symbols.mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen)
// phmx : HMIXER* optional, out -> "pointer"
// uMxId : DWORD -> "u32"
// dwCallback : UINT_PTR optional -> "usize"
// dwInstance : UINT_PTR optional -> "usize"
// fdwOpen : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t mixerOpen(
void* phmx,
uint32_t uMxId,
size_t dwCallback,
size_t dwInstance,
uint32_t fdwOpen);
C, "WINMM.dll");
// $ffi->mixerOpen(phmx, uMxId, dwCallback, dwInstance, fdwOpen);
// phmx : HMIXER* optional, out
// uMxId : DWORD
// dwCallback : UINT_PTR optional
// dwInstance : UINT_PTR optional
// fdwOpen : 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 mixerOpen(
Pointer phmx, // HMIXER* optional, out
int uMxId, // DWORD
long dwCallback, // UINT_PTR optional
long dwInstance, // UINT_PTR optional
int fdwOpen // DWORD
);
}@[Link("winmm")]
lib LibWINMM
fun mixerOpen = mixerOpen(
phmx : Void*, # HMIXER* optional, out
uMxId : UInt32, # DWORD
dwCallback : LibC::SizeT, # UINT_PTR optional
dwInstance : LibC::SizeT, # UINT_PTR optional
fdwOpen : 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 mixerOpenNative = Uint32 Function(Pointer<Void>, Uint32, UintPtr, UintPtr, Uint32);
typedef mixerOpenDart = int Function(Pointer<Void>, int, int, int, int);
final mixerOpen = DynamicLibrary.open('WINMM.dll')
.lookupFunction<mixerOpenNative, mixerOpenDart>('mixerOpen');
// phmx : HMIXER* optional, out -> Pointer<Void>
// uMxId : DWORD -> Uint32
// dwCallback : UINT_PTR optional -> UintPtr
// dwInstance : UINT_PTR optional -> UintPtr
// fdwOpen : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function mixerOpen(
phmx: Pointer; // HMIXER* optional, out
uMxId: DWORD; // DWORD
dwCallback: NativeUInt; // UINT_PTR optional
dwInstance: NativeUInt; // UINT_PTR optional
fdwOpen: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'mixerOpen';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "mixerOpen"
c_mixerOpen :: Ptr () -> Word32 -> CUIntPtr -> CUIntPtr -> Word32 -> IO Word32
-- phmx : HMIXER* optional, out -> Ptr ()
-- uMxId : DWORD -> Word32
-- dwCallback : UINT_PTR optional -> CUIntPtr
-- dwInstance : UINT_PTR optional -> CUIntPtr
-- fdwOpen : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mixeropen =
foreign "mixerOpen"
((ptr void) @-> uint32_t @-> size_t @-> size_t @-> uint32_t @-> returning uint32_t)
(* phmx : HMIXER* optional, out -> (ptr void) *)
(* uMxId : DWORD -> uint32_t *)
(* dwCallback : UINT_PTR optional -> size_t *)
(* dwInstance : UINT_PTR optional -> size_t *)
(* fdwOpen : 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 ("mixerOpen" mixer-open :convention :stdcall) :uint32
(phmx :pointer) ; HMIXER* optional, out
(u-mx-id :uint32) ; DWORD
(dw-callback :uint64) ; UINT_PTR optional
(dw-instance :uint64) ; UINT_PTR optional
(fdw-open :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $mixerOpen = Win32::API::More->new('WINMM',
'DWORD mixerOpen(HANDLE phmx, DWORD uMxId, WPARAM dwCallback, WPARAM dwInstance, DWORD fdwOpen)');
# my $ret = $mixerOpen->Call($phmx, $uMxId, $dwCallback, $dwInstance, $fdwOpen);
# phmx : HMIXER* optional, out -> HANDLE
# uMxId : DWORD -> DWORD
# dwCallback : UINT_PTR optional -> WPARAM
# dwInstance : UINT_PTR optional -> WPARAM
# fdwOpen : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。