Open Sound System
|Do you have problems with sound/audio application development? Don't panic! Click here for help!|
Scaling and interpretation of the actual mixer control value (see SNDCTL_MIX_READ and SNDCTL_MIX_WRITE) depends on the type of the control (oss_mixext.type).}
For the simple mixer control types (MIXT_ONOFF and MIXT_ENUM) the
maxvalue field contains the number of possible alternatives. So the possible value range is 0 to
maxvalue-1. In fact for MIXT_ONOFF only 0 and 1 are defined.
For the other mixer control types the the
maxvalue field gives the largest possible value. For example if maxvalue is 100 then the control can have any integer value between 0 and 100 (inclusive). In most cases the application can simply use this "raw" value range directly. However more sophisticated (GUI) mixers can also use the range mapping rules defined below.
Even the application uses value scaling the actual range of values passed to/from SNDCTL_MIX_WRITE/SNDCTL_MIX_READ is 0 to maxvalue. The scaled value should only be used in the GUI level. Scaling is only necessary if the exact numeric value is shown by the application or if the volume sliders have the numeric scale marked on them.
By convention larger mixer control value means louder voice. Usually value of 0 means the minimum volume. Sometimes 0 means that the signal is completely muted while sometimes it means that the volume level is almost unaudible (in such cases there is usually a separate "mute" control for the signal). Volume level of
maxvalue means loudest possible signal (unity gain or slight amplification).
Some "legacy" mixer controls (such as AC97 volumes) use arbitrary scale of 0 to 100 and the exact volume mapping is unspecified (depends on the driver). Recent OSS drivers use more precise volume scaling (maxvalue>100) and in such cases the volume is often in decibel scale.
In many cases the device supports just some of the values in the 0 to maxvalue range. Unsupported values will be rounded or truncated to the nearest supported value. Applications should avoid situations where this truncation makes the mixer application to drive the level down to zero.
minvalue field is used by some of the latest OSS drivers to specify different "user level" volume scaling. If minvalue is not zero then applications can use this field to scale the actual range shown to the user. The
minvalue field is simply added to the mixer value to get the user level value.
For example if maxvalue=140 and minvalue=-130 the possible "user level" volume range becomes -130 to 10. Value of 130 maps to 0 and 140 means +10. If decibel scale is used (MIXF_DECIBEL then value of 130 means unity gain and value of 140 means +10 dB amplification.
The application needs to substract
minvalue from the "user level" volume before writing the value to the device (usning SNDCTL_MIX_WRITE
By default the exact meaning of the mixer value/level is unspecified. Some drivers may actually use decibel scale but equally well the the scale may be anything else (all drivers using dB scale will be updated to report the MIXF_DECIBEL flag in the future). Applications should not assume dB scale if it's not explicitly reported.
Most OSS drivers use modifier flags such as MIXF_DECIBEL, MIXF_CENTIBEL or MIXF_HZ to specify the exact scaling. MIXF_CENTIBEL requires special handling in applications. The "scaled" mixer level read from the device can be scaled to dB scale by dividing it by 10. For example mixer level of 102 means 10.2 dB. This "user level" values should be multiplied by 10 before writing it to the device.