📄 mixer.cs
字号:
this.MicroPhoneVolumeRange=mxc.Bounds;
this.dwControlID_mircophone=mxc.dwControlID;
}
public void GetMicrophoneVolume(ref int left,ref int right)
{
this.GetVolume(dwControlID_mircophone,ref left,ref right);
}
public void SetMicrophoneVolume(int left,int right)
{
this.SetVolume(dwControlID_mircophone,left,right);
}
public void GetSpeakerVolume(ref int left,ref int right)
{
this.GetVolume(dwControlID_speaker,ref left,ref right);
}
public void SetSpeakerVolume(int left,int right)
{
this.SetVolume(dwControlID_speaker,left,right);
}
private void GetVolume(int controlid,ref int left,ref int right)
{
IntPtr volumes=Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(int))*2);
Marshal.WriteInt32(volumes,0);
Marshal.WriteInt32(volumes,4,0);
gowk.multimedia.MIXERCONTROLDETAILS details=new MIXERCONTROLDETAILS();
details.cbStruct=Marshal.SizeOf(details);
details.cChannels=1;
details.cbDetails=Marshal.SizeOf(typeof(int));
details.cMultipleItems=0;
details.dwControlID=controlid;
// details.paDetails=(int)volumes;
int ret=Mixer.mixerGetControlDetails(m_hmx,ref details,0);
left=Marshal.ReadInt32(volumes);
right=Marshal.ReadInt32(volumes,Marshal.SizeOf(typeof(int)));
}
private void SetVolume(int controlid,int left,int right)
{
IntPtr volumes=Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(int))*2);
Marshal.WriteInt32(volumes,left);
Marshal.WriteInt32(volumes,4,right);
gowk.multimedia.MIXERCONTROLDETAILS details=new MIXERCONTROLDETAILS();
details.cbStruct=Marshal.SizeOf(details);
details.cChannels=1;
details.cbDetails=Marshal.SizeOf(typeof(int));
details.cMultipleItems=0;
details.dwControlID=controlid;
// details.paDetails=(int)volumes;
int ret=Mixer.mixerSetControlDetails(m_hmx,ref details,0);
// left=Marshal.ReadInt32(volumes);
// right=Marshal.ReadInt32(volumes,Marshal.SizeOf(typeof(int)));
}*/
#endregion
#region
/* private void button3_Click(object sender, System.EventArgs e)
{
int rst;
rst=Mixer.mixerGetNumDevs();
rst=Mixer.mixerOpen(ref m_hmx,0,0,0,Mixer.MIXER_OBJECTF_MIXER);
MIXERCAPS caps=new MIXERCAPS();
rst=Mixer.mixerGetDevCaps(m_hmx,ref caps,Marshal.SizeOf(typeof(MIXERCAPS)));
MIXERLINE ml=new MIXERLINE();
ml.cbStruct=Marshal.SizeOf(ml);
ml.dwComponentType=Mixer.MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
rst=Mixer.mixerGetLineInfo((int)m_hmx,ref ml, Mixer.MIXER_OBJECTF_HMIXER|Mixer.MIXER_GETLINEINFOF_COMPONENTTYPE);
MIXERCONTROL mxc=new MIXERCONTROL();mxc.Bounds=new Volume();
MIXERLINECONTROLS mxlc=new MIXERLINECONTROLS();
IntPtr p=Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(MIXERCONTROL)));
Marshal.StructureToPtr(mxc,p,true);
mxlc.cbStruct = Marshal.SizeOf(typeof(MIXERLINECONTROLS));
mxlc.dwLineID =ml.dwLineID;
mxlc.dwControlType = Mixer.MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = Marshal.SizeOf(typeof(MIXERCONTROL));
mxlc.pamxctrl = p;
rst=Mixer.mixerGetLineControls((int)m_hmx,ref mxlc,Mixer.MIXER_OBJECTF_HMIXER |Mixer.MIXER_GETLINECONTROLSF_ONEBYTYPE);
mxc=(MIXERCONTROL)Marshal.PtrToStructure(mxlc.pamxctrl,typeof(MIXERCONTROL));
IntPtr volumes=Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(int))*2);
Marshal.WriteInt32(volumes,0);
Marshal.WriteInt32(volumes,4,0);
gowk.multimedia.MIXERCONTROLDETAILS details=new MIXERCONTROLDETAILS();
details.cbStruct=Marshal.SizeOf(details);
details.cChannels=2;
details.cbDetails=Marshal.SizeOf(typeof(int));
details.cMultipleItems=0;
details.dwControlID=mxc.dwControlID;
details.paDetails=(int)volumes;
rst=Mixer.mixerGetControlDetails(m_hmx,ref details,0);
int l=Marshal.ReadInt32(volumes);
int r=Marshal.ReadInt32(volumes,Marshal.SizeOf(typeof(int)));
}*/
#endregion
#region
[DllImport("winmm.dll", EntryPoint="mixerClose")]
public static extern int mixerClose (
int hmx
);
[DllImport("winmm.dll", EntryPoint="mixerGetControlDetails")]
public static extern int mixerGetControlDetails (
int hmxobj,
ref MIXERCONTROLDETAILS pmxcd,
int fdwDetails
);
[DllImport("winmm.dll", EntryPoint="mixerGetDevCaps")]
public static extern int mixerGetDevCaps (
int uMxId,
MIXERCAPS pmxcaps,
int cbmxcaps
);
[DllImport("winmm.dll", EntryPoint="mixerGetID")]
public static extern int mixerGetID (
int hmxobj,
ref int pumxID,
int fdwId
);
[DllImport("winmm.dll", EntryPoint="mixerGetLineControls")]
public static extern int mixerGetLineControls (
int hmxobj,
ref MIXERLINECONTROLS pmxlc,
int fdwControls
);
[DllImport("winmm.dll", EntryPoint="mixerGetLineInfo")]
public static extern int mixerGetLineInfo (
int hmxobj,
ref MIXERLINE pmxl,
int fdwInfo
);
[DllImport("winmm.dll", EntryPoint="mixerGetNumDevs")]
public static extern int mixerGetNumDevs ();
[DllImport("winmm.dll", EntryPoint="mixerMessage")]
public static extern int mixerMessage (
int hmx,
int uMsg,
int dwParam1,
int dwParam2
);
[DllImport("winmm.dll", EntryPoint="mixerOpen")]
public static extern int mixerOpen (
ref int phmx,
int uMxId,
int dwCallback,
int dwInstance,
int fdwOpen
);
[DllImport("winmm.dll", EntryPoint="mixerSetControlDetails")]
public static extern int mixerSetControlDetails (
int hmxobj,
ref MIXERCONTROLDETAILS pmxcd,
int fdwDetails
);
[DllImport("winmm.dll", EntryPoint="mixerClose")]
public static extern int mixerClose (
IntPtr hmx
);
[DllImport("winmm.dll", EntryPoint="mixerGetControlDetails")]
public static extern int mixerGetControlDetails (
IntPtr hmxobj,
ref MIXERCONTROLDETAILS pmxcd,
uint fdwDetails
);
[DllImport("winmm.dll", EntryPoint="mixerGetDevCaps")]
public static extern int mixerGetDevCaps (
IntPtr uMxId,
ref MIXERCAPS pmxcaps,
int cbmxcaps
);
[DllImport("winmm.dll", EntryPoint="mixerGetID")]
public static extern int mixerGetID (
IntPtr hmxobj,
ref int pumxID,
uint fdwId
);
[DllImport("winmm.dll", EntryPoint="mixerGetLineControls")]
public static extern int mixerGetLineControls (
int hmxobj,
ref MIXERLINECONTROLS pmxlc,
uint fdwControls
);
[DllImport("winmm.dll", EntryPoint="mixerGetLineInfo")]
public static extern int mixerGetLineInfo (
int hmxobj,
ref MIXERLINE pmxl,
uint fdwInfo
);
[DllImport("winmm.dll", EntryPoint="mixerMessage")]
public static extern int mixerMessage (
IntPtr hmx,
int uMsg,
int dwParam1,
int dwParam2
);
[DllImport("winmm.dll", EntryPoint="mixerOpen")]
public static extern int mixerOpen (
ref IntPtr phmx,
int uMxId,
int dwCallback,
int dwInstance,
uint fdwOpen
);
[DllImport("winmm.dll", EntryPoint="mixerSetControlDetails")]
public static extern int mixerSetControlDetails (
IntPtr hmxobj,
ref MIXERCONTROLDETAILS pmxcd,
uint fdwDetails
);
public const uint MIXER_OBJECTF_HANDLE =0x80000000;
public const int MIXER_OBJECTF_MIXER =0x00000000;
public const uint MIXER_OBJECTF_HMIXER =(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIXER);
public const int MIXER_OBJECTF_WAVEOUT =0x10000000;
//public const int MIXER_OBJECTF_HWAVEOUT =(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEOUT);
public const int MIXER_OBJECTF_WAVEIN =0x20000000;
//public const int MIXER_OBJECTF_HWAVEIN =(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEIN);
public const int MIXER_OBJECTF_MIDIOUT =0x30000000;
//public const int MIXER_OBJECTF_HMIDIOUT =(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIOUT);
public const int MIXER_OBJECTF_MIDIIN =0x40000000;
//public const int MIXER_OBJECTF_HMIDIIN =(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIIN);
public const int MIXER_OBJECTF_AUX =0x50000000;
public const int MIXER_GETLINEINFOF_DESTINATION = 0x00000000;
public const int MIXER_GETLINEINFOF_SOURCE =0x00000001;
public const int MIXER_GETLINEINFOF_LINEID =0x00000002;
public const int MIXER_GETLINEINFOF_COMPONENTTYPE =0x00000003;
public const int MIXERLINE_COMPONENTTYPE_DST_FIRST =0x00000000;
public const int MIXERLINE_COMPONENTTYPE_DST_SPEAKERS =(MIXERLINE_COMPONENTTYPE_DST_FIRST + 4);
public const int MIXERLINE_COMPONENTTYPE_SRC_FIRST =0x00001000;
public const int MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE =(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
public const int MIXERLINE_COMPONENTTYPE_DST_WAVEIN =(MIXERLINE_COMPONENTTYPE_DST_FIRST + 7);
public const int MIXERCONTROL_CT_CLASS_FADER =0x50000000;
public const int MIXERCONTROL_CT_UNITS_UNSIGNED =0x00030000;
public const int MIXERCONTROL_CT_CLASS_SWITCH =0x20000000;
public const int MIXERCONTROL_CT_SC_SWITCH_BOOLEAN =0x00000000;
public const int MIXERCONTROL_CT_UNITS_BOOLEAN = 0x00010000;
public const int MIXERCONTROL_CONTROLTYPE_BOOLEAN =(MIXERCONTROL_CT_CLASS_SWITCH | MIXERCONTROL_CT_SC_SWITCH_BOOLEAN | MIXERCONTROL_CT_UNITS_BOOLEAN);
public const int MIXERCONTROL_CONTROLTYPE_FADER =(MIXERCONTROL_CT_CLASS_FADER | MIXERCONTROL_CT_UNITS_UNSIGNED);
public const int MIXERCONTROL_CONTROLTYPE_VOLUME =(MIXERCONTROL_CONTROLTYPE_FADER + 1);
public const int MIXERCONTROL_CONTROLTYPE_MUTE =(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2);
public const int MIXER_GETLINECONTROLSF_ONEBYTYPE =0x00000002;
public const int MIXER_GETCONTROLDETAILSF_VALUE = 0x00000000;
public const int MM_MIXM_LINE_CHANGE =0x3D0; /* mixer line change notify */
public const int MM_MIXM_CONTROL_CHANGE =0x3D1; /* mixer control change notify */
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -