Technical Q&As


SND11 - Setting Audio Input Gain (10-February-98)


Q My program used to set the gain to 1.5, which worked without any problems. With Mac OS 8.1, when I set the gain to 1.5, I get clipping. What happened?

A Mac OS 8.1 changed the gain so that all of the hardware's possible gain is usable. In the past, some Macs were not using the full gain that the hardware could provide (which isn't specified and varies from Mac to Mac). Now the 0.5 to 1.5 values will map to the minimum and maximum gain possible.

On the AWAC sound chip, there are two gain amplifiers for input A: one that is on or off and provides 24 dB of gain, and another that has 16 steps of 1.5 dB each (22.5 dB total). Before Mac OS 8.1, the 24 dB gain circuit was never used, but now it is. This gives a 5-bit gain that can be adjusted in 32 steps of 1.5 dB each. These 32 steps are mapped into the 0.5 to 1.5 value that is passed to the sound input driver via siInputGain.

The Screamer chip has basically the same capabilities, but for both input A and input B.

The only problem with all of this is that you don't generally know which input you are connected to. In the general case (you can figure out what audio chip you are on without a problem), even the developer notes don't say which inputs are connected to which input ports on the sound chip.

The general solution to overdriving the input may be to provide a slider that adjusts the input gain so that the user can control it, or you can control the gain programmatically to reduce clipping if you detect that three or more continuous samples have the maximum input level value.



-- Mark Cookson
Worldwide Developer Technical Support

Technical Q&As
Previous Question | Contents | Next Question

To contact us, please use the Contact Us page.