📄 wmaudiosignals.c
字号:
int attenuationdBRight
)
{
WMSTATUS status;
/*
* Call through to our helper function.
*/
status = private_Set2ChannelVolumeBase( hDevice,
outputL,
outputR,
WM_SIGNAL_LEVEL( -attenuationdBLeft ),
WM_SIGNAL_LEVEL( -attenuationdBRight )
);
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioSetInputGains
*
* Called to set the gain applied to a given input.
* For example, a 0dBFS input with 6dB gain would result in the input signal
* being increased by +6dBFS.
*
* Note: the underlying device may not use dB step sizes. In this case the
* applied gain will be rounded to the nearest available step. For
* example, if the device has a 1.5dB step size (typical of AC'97 devices),
* an gain of either 4dB or 5dB would result in a +4.5dBFS signal.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* inputL left input to gain
* inputR right input to gain
* gain_dBL left channel gain to apply in dB steps.
* gain_dBR right channel gain to apply in dB steps.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetInputGains( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL inputL,
WM_AUDIO_SIGNAL inputR,
int gain_dBL,
int gain_dBR
)
{
WMSTATUS status;
/*
* Call through to our helper function.
*/
status = private_Set2ChannelVolumeBase( hDevice,
inputL,
inputR,
WM_SIGNAL_LEVEL( gain_dBL ),
WM_SIGNAL_LEVEL( gain_dBR )
);
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioSetOutputVolumes
*
* Called to set the perceived volume for the left and right channels
* of a given analogue output.
*
* Note: Linearly reducing the perceived volume does _not_ result in a linear
* attenuation of the output signal.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* output output to attenuate
* volPercentL left channel perceived output volume,
* as a percentage of full-scale
* volPercentR Right channel perceived output volume,
* as a percentage of full-scale
* channels indicates channel(s) to set attenuation on.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetOutputVolumes( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL output,
unsigned int volPercentL,
unsigned int volPercentR,
WM_AUDIO_CHANNELS channels
)
{
WMSTATUS status;
unsigned int leftVol, rightVol;
leftVol = 65535 * volPercentL / 100;
rightVol = 65535 * volPercentR / 100;
status = WMAudioSetSignalVolumes( hDevice, output, leftVol, rightVol );
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioSetOutputAttenuationsAC97
*
* Called to set the left and right channel attenuations applied to a given
* analogue output, using the AC97 attenuation values to write to the register
* - 1.5dB steps.
* Note:
* At the moment we only support setting the attenuation on 2 outputs if they
* have the same control register
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* outputL left output to attenuate
* outputR right output to attenuate
* rawValL left channel attenuation to apply in 1.5dB steps.
* rawValR right channel attenuation to apply in 1.5dB steps.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetOutputAttenuationsAC97( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL outputL,
WM_AUDIO_SIGNAL outputR,
int rawValL,
int rawValR
)
{
WMSTATUS status;
/*
* Call through to our helper function.
*/
status = private_Set2ChannelVolumeBase( hDevice,
outputL,
outputR,
WM_SIGNAL_LEVEL_AC97( -rawValL ),
WM_SIGNAL_LEVEL_AC97( -rawValR )
);
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioGetOutputAttenuationsAC97
*
* Called to get the left and right channel attenuations set at a given
* analogue output, outputiing the AC97 attenuation values obtained from the
* registers - 1.5dB steps.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* output output to attenuate
* rawValL left channel attenuation to get.
* rawValR right channel attenuation to get.
* channels indicates channel(s) attenuations to get.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioGetOutputAttenuationsAC97( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL output,
int *rawValL,
int *rawValR,
WM_AUDIO_CHANNELS channels
)
{
WMSTATUS status;
/*
* Get left if asked for.
*/
if ( rawValL && channels & WM_CHANNEL_LEFT )
{
status = private_GetSignalVolumeUnits( hDevice,
output,
rawValL,
WM_CHANNEL_LEFT,
WM_SIGNAL_LEVEL_AC97( -1 )
);
if ( WM_ERROR( status ) )
{
goto finish;
}
}
/*
* And right.
*/
if ( rawValR && channels & WM_CHANNEL_RIGHT )
{
status = private_GetSignalVolumeUnits( hDevice,
output,
rawValR,
WM_CHANNEL_RIGHT,
WM_SIGNAL_LEVEL_AC97( -1 )
);
if ( WM_ERROR( status ) )
{
goto finish;
}
}
/*
* And return.
*/
finish:
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioSetInputGainsAC97
*
* Called to set the gain applied to a given input, using the AC97
* gain value to write to the register - All the inputs have a range of
* +12dB to -34.5dB gain in 1.5dB steps except for PCBEEP.
* PCBEEP on WM9705/07 has a range of 0dB to -45dB in 3dB steps.
* PCBEEP on WM9712/13 has a range of 6dB to -15dB in 3dB steps.
*
* NOTE: If we need to set gains for two entirely different inputs we will need
* to set (seperate) details for both the left and right imputs simultaneously.
* This is not currently supported so WMAudioSetInputGainsAC97 must be called
* separately to alter the left and right signals.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* inputL left input to apply gain to.
* inputR right input to apply gain to.
* rawValL left channel gain to apply in 1.5dB steps.
* rawValR right channel gain to apply in 1.5dB steps.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetInputGainsAC97( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL inputL,
WM_AUDIO_SIGNAL inputR,
WM_REGVAL rawValL,
WM_REGVAL rawValR
)
{
WMSTATUS status;
/*
* Call through to our helper function.
*/
status = private_Set2ChannelVolumeBase( hDevice,
inputL,
inputR,
WM_SIGNAL_LEVEL_AC97( rawValL ),
WM_SIGNAL_LEVEL_AC97( rawValR )
);
return status;
}
/*-----------------------------------------------------------------------------
* Function: WMAudioSetADCGainsAC97
*
* Called to set the ADC gain, using the AC97 gain value to write to the register.
* The gain is only applied as indicated by the channels field.
* The record gain has a standard range of 0dB to +22.5dB in steps of 1.5dB.
* For devices that support extended ranges this is -17.25dB to +30dB in steps
* of 0.75dB.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* rawValL left channel gain to apply in 1.5dB steps.
* rawValR right chanel gain to apply in 1.5dB steps.
* channels indicates ADC channel(s) to set gain on.
* extended use extended range if TRUE, use standard range if FALSE.
*
* Returns: WMSTATUS
* See WMStatus.h.
*---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetADCGainsAC97( WM_DEVICE_HANDLE hDevice,
WM_REGVAL rawValL,
WM_REGVAL rawValR,
WM_AUDIO_CHANNELS channels,
WM_BOOL extended
)
{
WM_REGVAL leftVal = rawValL;
WM_REGVAL rightVal = rawValR;
WM_REGTYPE reg;
WM_REGVAL regVal=0; /* keeps compiler happy */
WMSTATUS status;
WM_REGVAL mask=0;
WM_REGVAL mute;
WM_SIGNAL_FLAGS field;
WM_SIGNAL_FLAGS fieldType;
const WM_SIGNAL_DETAILS *pSignalDetails = NULL;
/* Ensure that we are setting at least 1 channel */
if ( !(WM_CHANNEL_STEREO & channels) )
{
WM_ASSERT( hDevice, ( WM_CHANNEL_STEREO & channels ) );
status = WMS_INVALID_PARAMETER;
goto error;
}
/*
* Check to see if this device supports extended ADC gain range.
*/
if( extended && ( !WM_HAS_EXTENDED_ADC_GAIN_RANGE( hDevice ) ) )
{
status = WMS_UNSUPPORTED;
goto error;
}
/* Get the signal details */
pSignalDetails = private_SignalDetails( hDevice, WM_AUDIO_STEREO_ADC );
if ( !pSignalDetails )
{
status = WMS_UNSUPPORTED;
goto error;
}
reg = pSignalDetails->reg;
field = pSignalDetails->flags;
fieldType = field & WM_SIG_TYPE_MASK;
mute = pSignalDetails->mute;
/*
* If this is not an ADC signal then return
* that this is operation is unsupported.
*/
if( WM_SIG_ADC != fieldType )
{
status = WMS_UNSUPPORTED;
goto error;
}
/*
* Crop the gain to its maximum value.
*/
if( extended )
{
if ( WM97_MAX_EXTENDED_ADC_GAIN < leftVal )
{
leftVal = WM97_MAX_EXTENDED_ADC_GAIN;
}
if ( WM97_MAX_EXTENDED_ADC_GAIN < righ
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -