波形音量: function GetWaveVolume(var Value: Byte; var ErrorStr: String): Boolean; var Error: LongInt; hMix: HMIXER; Ml: MIXERLINE; Mc: MIXERCONTROL; Mlc: MIXERLINECONTROLS; Mcd: TMIXERCONTROLDETAILS; Mcdu: MIXERCONTROLDETAILS_UNSIGNED; begin Error := mixerOpen(@hMix, 0, 0, 0, 0); Result := Error = MMSYSERR_NOERROR; if Result then begin try ml.cbStruct := sizeof(MIXERLINE); ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; // get the Wave line of the mixer device Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE); Result := Error = MMSYSERR_NOERROR; if Result then begin mlc.cbStruct := sizeof(MIXERLINECONTROLS); mlc.dwLineID := ml.dwLineID; mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mlc.cControls := 1; mlc.pamxctrl := @mc; mlc.cbmxctrl := sizeof(MIXERCONTROL); // get the volume controls associated with the Waveout line Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); REsult := MMSYSERR_NOERROR = Error; if Result then begin mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100)); mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS); mcd.hwndOwner := 0; mcd.dwControlID := mc.dwControlID; mcd.paDetails := @mcdu; mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels := 1; // set the volume Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE); Value := Round((mcdu.dwValue * 100)/Mc.Bounds.dwMaximum); Result := Error = MMSYSERR_NOERROR; if not Result then ErrorStr := 'MixerGetControlDetails() Failed!'; end else ErrorStr := 'MixerGetLineControls() Failed!'; end else ErrorStr := 'MixerGetLineInfo() Failed!'; finally MixerClose(hMix); end; end else ErrorStr := 'MixerOpen() Failed!'; end; function SetWaveVolume(const Value: Byte; var ErrorStr: String): Boolean; var Error: LongInt; hMix: HMIXER; Ml: MIXERLINE; Mc: MIXERCONTROL; Mlc: MIXERLINECONTROLS; Mcd: TMIXERCONTROLDETAILS; Mcdu: MIXERCONTROLDETAILS_UNSIGNED; begin Error := mixerOpen(@hMix, 0, 0, 0, 0); Result := Error = MMSYSERR_NOERROR; if Result then begin try ml.cbStruct := sizeof(MIXERLINE); ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; // get the Wave line of the mixer device Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE); Result := Error = MMSYSERR_NOERROR; if Result then begin mlc.cbStruct := sizeof(MIXERLINECONTROLS); mlc.dwLineID := ml.dwLineID; mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mlc.cControls := 1; mlc.pamxctrl := @mc; mlc.cbmxctrl := sizeof(MIXERCONTROL); // get the volume controls associated with the Waveout line Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); REsult := MMSYSERR_NOERROR = Error; if Result then begin mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100)); mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS); mcd.hwndOwner := 0; mcd.dwControlID := mc.dwControlID; mcd.paDetails := @mcdu; mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels := 1; // set the volume Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE); Result := Error = MMSYSERR_NOERROR; if not Result then ErrorStr := 'MixerSetControlDetails() Failed!'; end else ErrorStr := 'MixerGetLineControls() Failed!'; end else ErrorStr := 'MixerGetLineInfo() Failed!'; finally MixerClose(hMix); end; end else ErrorStr := 'MixerOpen() Failed!'; end;
主音量: function GetMasterVolume(var Value: Byte; var ErrorStr: String): Boolean; var Error: LongInt; hMix: HMIXER; Ml: MIXERLINE; Mc: MIXERCONTROL; Mlc: MIXERLINECONTROLS; Mcd: TMIXERCONTROLDETAILS; Mcdu: MIXERCONTROLDETAILS_UNSIGNED; begin Error := mixerOpen(@hMix, 0, 0, 0, 0); Result := Error = MMSYSERR_NOERROR; if Result then begin try ml.cbStruct := sizeof(MIXERLINE); ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; // get the speaker line of the mixer device Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE); Result := Error = MMSYSERR_NOERROR; if Result then begin mlc.cbStruct := sizeof(MIXERLINECONTROLS); mlc.dwLineID := ml.dwLineID; mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mlc.cControls := 1; mlc.pamxctrl := @mc; mlc.cbmxctrl := sizeof(MIXERCONTROL); // get the volume controls associated with the speaker line Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); REsult := MMSYSERR_NOERROR = Error; if Result then begin mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100)); mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS); mcd.hwndOwner := 0; mcd.dwControlID := mc.dwControlID; mcd.paDetails := @mcdu; mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels := 1; // set the volume Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE); Value := Round(mcdu.dwValue * 100 / Mc.Bounds.dwMaximum); Result := Error = MMSYSERR_NOERROR; if not Result then ErrorStr := 'MixerGetControlDetails() Failed!'; end else ErrorStr := 'MixerGetLineControls() Failed!'; end else ErrorStr := 'MixerGetLineInfo() Failed!'; finally MixerClose(hMix); end; end else ErrorStr := 'MixerOpen() Failed!'; end;function SetMasterVolume(const Value: Byte; var ErrorStr: String): Boolean; var Error: LongInt; hMix: HMIXER; Ml: MIXERLINE; Mc: MIXERCONTROL; Mlc: MIXERLINECONTROLS; Mcd: TMIXERCONTROLDETAILS; Mcdu: MIXERCONTROLDETAILS_UNSIGNED; begin Error := mixerOpen(@hMix, 0, 0, 0, 0); Result := Error = MMSYSERR_NOERROR; if Result then begin try ml.cbStruct := sizeof(MIXERLINE); ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; // get the speaker line of the mixer device Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE); Result := Error = MMSYSERR_NOERROR; if Result then begin mlc.cbStruct := sizeof(MIXERLINECONTROLS); mlc.dwLineID := ml.dwLineID; mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mlc.cControls := 1; mlc.pamxctrl := @mc; mlc.cbmxctrl := sizeof(MIXERCONTROL); // get the volume controls associated with the speaker line Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); REsult := MMSYSERR_NOERROR = Error; if Result then begin mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100)); mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS); mcd.hwndOwner := 0; mcd.dwControlID := mc.dwControlID; mcd.paDetails := @mcdu; mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels := 1; // set the volume Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE); Result := Error = MMSYSERR_NOERROR; if not Result then ErrorStr := 'MixerSetControlDetails() Failed!'; end else ErrorStr := 'MixerGetLineControls() Failed!'; end else ErrorStr := 'MixerGetLineInfo() Failed!'; finally MixerClose(hMix); end; end else ErrorStr := 'MixerOpen() Failed!'; end;
function GetWaveVolume(var Value: Byte; var ErrorStr: String): Boolean;
var
Error: LongInt;
hMix: HMIXER;
Ml: MIXERLINE;
Mc: MIXERCONTROL;
Mlc: MIXERLINECONTROLS;
Mcd: TMIXERCONTROLDETAILS;
Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
begin
Error := mixerOpen(@hMix, 0, 0, 0, 0);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
try
ml.cbStruct := sizeof(MIXERLINE);
ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
// get the Wave line of the mixer device
Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
mlc.cbStruct := sizeof(MIXERLINECONTROLS);
mlc.dwLineID := ml.dwLineID;
mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
mlc.cControls := 1;
mlc.pamxctrl := @mc;
mlc.cbmxctrl := sizeof(MIXERCONTROL);
// get the volume controls associated with the Waveout line
Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
REsult := MMSYSERR_NOERROR = Error;
if Result then begin
mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100));
mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS);
mcd.hwndOwner := 0;
mcd.dwControlID := mc.dwControlID;
mcd.paDetails := @mcdu;
mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.cChannels := 1;
// set the volume
Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
Value := Round((mcdu.dwValue * 100)/Mc.Bounds.dwMaximum);
Result := Error = MMSYSERR_NOERROR;
if not Result then ErrorStr := 'MixerGetControlDetails() Failed!';
end else ErrorStr := 'MixerGetLineControls() Failed!';
end else ErrorStr := 'MixerGetLineInfo() Failed!';
finally
MixerClose(hMix);
end;
end else ErrorStr := 'MixerOpen() Failed!';
end;
function SetWaveVolume(const Value: Byte; var ErrorStr: String): Boolean;
var
Error: LongInt;
hMix: HMIXER;
Ml: MIXERLINE;
Mc: MIXERCONTROL;
Mlc: MIXERLINECONTROLS;
Mcd: TMIXERCONTROLDETAILS;
Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
begin
Error := mixerOpen(@hMix, 0, 0, 0, 0);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
try
ml.cbStruct := sizeof(MIXERLINE);
ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
// get the Wave line of the mixer device
Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
mlc.cbStruct := sizeof(MIXERLINECONTROLS);
mlc.dwLineID := ml.dwLineID;
mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
mlc.cControls := 1;
mlc.pamxctrl := @mc;
mlc.cbmxctrl := sizeof(MIXERCONTROL);
// get the volume controls associated with the Waveout line
Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
REsult := MMSYSERR_NOERROR = Error;
if Result then begin
mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100));
mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS);
mcd.hwndOwner := 0;
mcd.dwControlID := mc.dwControlID;
mcd.paDetails := @mcdu;
mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.cChannels := 1;
// set the volume
Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
Result := Error = MMSYSERR_NOERROR;
if not Result then ErrorStr := 'MixerSetControlDetails() Failed!';
end else ErrorStr := 'MixerGetLineControls() Failed!';
end else ErrorStr := 'MixerGetLineInfo() Failed!';
finally
MixerClose(hMix);
end;
end else ErrorStr := 'MixerOpen() Failed!';
end;
function GetMasterVolume(var Value: Byte; var ErrorStr: String): Boolean;
var
Error: LongInt;
hMix: HMIXER;
Ml: MIXERLINE;
Mc: MIXERCONTROL;
Mlc: MIXERLINECONTROLS;
Mcd: TMIXERCONTROLDETAILS;
Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
begin
Error := mixerOpen(@hMix, 0, 0, 0, 0);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
try
ml.cbStruct := sizeof(MIXERLINE);
ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
// get the speaker line of the mixer device
Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
mlc.cbStruct := sizeof(MIXERLINECONTROLS);
mlc.dwLineID := ml.dwLineID;
mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
mlc.cControls := 1;
mlc.pamxctrl := @mc;
mlc.cbmxctrl := sizeof(MIXERCONTROL);
// get the volume controls associated with the speaker line
Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
REsult := MMSYSERR_NOERROR = Error;
if Result then begin
mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100));
mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS);
mcd.hwndOwner := 0;
mcd.dwControlID := mc.dwControlID;
mcd.paDetails := @mcdu;
mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.cChannels := 1;
// set the volume
Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
Value := Round(mcdu.dwValue * 100 / Mc.Bounds.dwMaximum);
Result := Error = MMSYSERR_NOERROR;
if not Result then ErrorStr := 'MixerGetControlDetails() Failed!';
end else ErrorStr := 'MixerGetLineControls() Failed!';
end else ErrorStr := 'MixerGetLineInfo() Failed!';
finally
MixerClose(hMix);
end;
end else ErrorStr := 'MixerOpen() Failed!';
end;function SetMasterVolume(const Value: Byte; var ErrorStr: String): Boolean;
var
Error: LongInt;
hMix: HMIXER;
Ml: MIXERLINE;
Mc: MIXERCONTROL;
Mlc: MIXERLINECONTROLS;
Mcd: TMIXERCONTROLDETAILS;
Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
begin
Error := mixerOpen(@hMix, 0, 0, 0, 0);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
try
ml.cbStruct := sizeof(MIXERLINE);
ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
// get the speaker line of the mixer device
Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
Result := Error = MMSYSERR_NOERROR;
if Result then begin
mlc.cbStruct := sizeof(MIXERLINECONTROLS);
mlc.dwLineID := ml.dwLineID;
mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
mlc.cControls := 1;
mlc.pamxctrl := @mc;
mlc.cbmxctrl := sizeof(MIXERCONTROL);
// get the volume controls associated with the speaker line
Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
REsult := MMSYSERR_NOERROR = Error;
if Result then begin
mcdu.dwValue := Round(Mc.Bounds.dwMaximum * (Value / 100));
mcd.cbStruct := sizeof(TMIXERCONTROLDETAILS);
mcd.hwndOwner := 0;
mcd.dwControlID := mc.dwControlID;
mcd.paDetails := @mcdu;
mcd.cbDetails := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.cChannels := 1;
// set the volume
Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
Result := Error = MMSYSERR_NOERROR;
if not Result then ErrorStr := 'MixerSetControlDetails() Failed!';
end else ErrorStr := 'MixerGetLineControls() Failed!';
end else ErrorStr := 'MixerGetLineInfo() Failed!';
finally
MixerClose(hMix);
end;
end else ErrorStr := 'MixerOpen() Failed!';
end;