📄 cmpmidimixer.pas
字号:
fValue [control, mcLeft] := data [0];
if channels = 1 then
fValue [control, mcRight] := data [0]
else
fValue [control, mcRight] := data [1]
end
else raise EMMError.CreateMMErr (err, 'mixerGetControlDetails')
end
else
begin
fValue [control, mcLeft] := 0;
fValue [control, mcRight] := 0
end
end;
(*--------------------------------------------------------------------------*
| procedure TMidiMixer.SetControl |
| |
| Set an MM control from the values held in the fValue member array. |
| |
| Parameters: |
| control : TMixerControlType The control to set |
| channels : Integer Number of channels to set. Usually 2. |
*--------------------------------------------------------------------------*)
procedure TMidiMixer.SetControl (control : TMixerControlType; channels : Integer);
var
details : TMixerControlDetails;
data : array [0..1024] of Integer;
err : Integer;
begin
if (fControl [control].dwControlType and MIXERCONTROL_CONTROLTYPE_CUSTOM) > 0 then
channels := 0 // Not used by TMidiMixer
else
if (fControl [control].fdwControl and MIXERCONTROL_CONTROLF_UNIFORM) > 0 then
channels := 1; // nb, Mute is often a 'uniform' control -
// there's only one value, which affects
// all channels.
FillChar (data, SizeOf (data), 0);
data [0] := fValue [control, mcLeft];
data [1] := fValue [control, mcRight];
details.cbStruct := sizeof (details);
details.dwControlID := fControl [control].dwControlID;
details.cChannels := channels;
details.cMultipleItems := fControl [control].cMultipleItems;
details.cbDetails := sizeof (integer);
details.paDetails := @data;
// Set the control's details.
err := mixerSetControlDetails (fMixerHandle, @details, MIXER_GETCONTROLDETAILSF_VALUE);
if err <> 0 then
raise EMMError.CreateMMErr (err, 'mixerSetControlDetails');
end;
(*--------------------------------------------------------------------------*
| procedure TMidiMixer.SetActive (value : boolean); |
| |
| 'Set' procedure for Active property. Open the mixer if we're not in |
| design mode. Also see the 'Loaded' procedure, above |
| |
| Parameters: |
| value : boolean The value to set |
*--------------------------------------------------------------------------*)
procedure TMidiMixer.SetActive (value : boolean);
begin
if value <> fActive then
if (csDesigning in ComponentState) or (csLoading in ComponentState) then
fActive := value
else
if value then Open else Close
end;
(*--------------------------------------------------------------------------*
| procedure TMidiMixer.SetMidiDeviceID (value : Integer); |
| |
| 'Set' procedure for MidiDeviceID property |
| |
| Parameters: |
| value : Integer The value to set. |
*--------------------------------------------------------------------------*)
procedure TMidiMixer.SetMidiDeviceID (value : Integer);
var
oldActive : boolean;
begin
if value <> fMidiDeviceID then
begin
oldActive := Active;
Close; // Close and re-open if the control's active
fMidiDeviceID := value;
Active := oldActive
end
end;
(*--------------------------------------------------------------------------*
| procedure TMidiMixer.SetControlValue (); |
| |
| 'Set' procedure for ControlValue property. Sets the MM device to the |
| specifued volume or mute value. |
| |
| Parameters: |
| ctrl : TMixerControlType The control to set |
| chan : TMixerChannel The channel to use (mcLeft or mcRight) |
| value : Integer The new value. |
*--------------------------------------------------------------------------*)
procedure TMidiMixer.SetControlValue (ctrl : TMixerControlType; chan : TMixerChannel; value : Integer);
var
cChannels : Integer;
begin
if fValue [ctrl, chan] <> value then
begin
if ctrl in [mtAudioVolume, mtAudioMute, mtAudioTreble, mtAudioBass] then
cChannels := fAudioLine.cChannels
else
cChannels := fSynthLine.cChannels;
fValue [ctrl, chan] := value;
SetControl (ctrl, cChannels)
end
end;
(*--------------------------------------------------------------------------*
| procedure TMidiMixer.SetControlValues (); |
| |
| 'Set' procedure for ControlValues property. Sets the MM device to the |
| specified volume or mute value for all channels. |
| |
| Parameters: |
| ctrl : TMixerControlType The control to set |
| chan : TMixerChannel The channel to use (mcLeft or mcRight) |
| value : Integer The new value. |
*--------------------------------------------------------------------------*)
procedure TMidiMixer.SetControlValues (ctrl : TMixerControlType; const values : TChannelValues);
var
cChannels : Integer;
begin
if ctrl in [mtAudioVolume, mtAudioMute, mtAudioTreble, mtAudioBass] then
cChannels := fAudioLine.cChannels
else
cChannels := fSynthLine.cChannels;
fValue [ctrl] := values;
SetControl (ctrl, cChannels)
end;
(*--------------------------------------------------------------------------*
| function TMidiMixer.GetControlValue () : Integer |
| |
| 'Get' function for ControlValue property. Gets the current value for a |
| control/channel |
| |
| Parameters: |
| ctrl : TMixerControlType The control to set |
| chan : TMixerChannel The channel to use (mcLeft or mcRight) |
| |
| The function returns the current value for the control/channel |
*--------------------------------------------------------------------------*)
function TMidiMixer.GetControlValue (ctrl : TMixerControlType; chan : TMixerChannel) : Integer;
begin
result := fValue [ctrl, chan];
end;
(*--------------------------------------------------------------------------*
| function TMidiMixer.GetControlSupported () : Boolean |
| |
| 'Get' function for ControlSupported property. Returns true if the |
| specified control is supported. |
| |
| Parameters: |
| ctrl : TMixerControlType The control to inspect. |
| |
| The function returns true if the MM subsystem supports the control. |
*--------------------------------------------------------------------------*)
function TMidiMixer.GetControlSupported (ctrl : TMixerControlType) : Boolean;
begin
result := fControlSupported [ctrl]
end;
(*--------------------------------------------------------------------------*
| function TMidiMixer.GetControlMin() : Integer |
| |
| 'Get' function for ControlMin property. Returns the minimum value for |
| the control. |
| |
| Parameters: |
| ctrl : TMixerControlType The control to inspect. |
| |
| The function returns the minimum value for the control. |
*--------------------------------------------------------------------------*)
function TMidiMixer.GetControlMin (ctrl : TMixerControlType) : Integer;
begin
result := fControl [ctrl].Bounds.lMinimum
end;
(*--------------------------------------------------------------------------*
| function TMidiMixer.GetControlMax() : Integer |
| |
| 'Get' function for ControlMax property. Returns the maximum value for |
| the control. |
| |
| Parameters: |
| ctrl : TMixerControlType The control to inspect. |
| |
| The function returns the maximum value for the control. |
*--------------------------------------------------------------------------*)
function TMidiMixer.GetControlMax (ctrl : TMixerControlType) : Integer;
begin
result := fControl [ctrl].Bounds.lMaximum
end;
(*--------------------------------------------------------------------------*
| procedure Register |
| |
| Register the TMidiMixer control with Delphi. |
*--------------------------------------------------------------------------*)
procedure Register;
begin
RegisterComponents('MIDI', [TMidiMixer]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -