简体   繁体   English

增加音频设备的输出增益

[英]Increasing Audio Device output Gain

I want to increase my virtual audio device gain. 我想增加虚拟音频设备的增益。 The Volume is turned all the way up but I can barely hear the audio. 音量一直调到最高,但我几乎听不到声音。 To do this I think we should look at the gain IOAudioLevelControl::createVolumeControl in IOAudioDevice. 为此,我认为我们应该看看IOAudioLevelControl::createVolumeControl中的IOAudioLevelControl IOAudioLevelControl::createVolumeControl增益。 This is Soundflower code 这是Soundflower代码

 // Gain control for each channel
    control = IOAudioLevelControl::createVolumeControl(SoundflowerDevice::kGainMax,         // Initial value
                                                       0,                                   // min value
                                                       SoundflowerDevice::kGainMax,         // max value
                                                       0,                                   // min 0.0 in IOFixed
                                                       (40 << 16) + (32768),                // 72 in IOFixed (16.16)
                                                       channel,                             // kIOAudioControlChannelIDDefaultLeft,
                                                       channelNameMap[channel],             // kIOAudioControlChannelNameLeft,
                                                       channel,                             // control ID - driver-defined
                                                       kIOAudioControlUsageInput);
    addControl(control, (IOAudioControl::IntValueChangeHandler)gainChangeHandler);

It seems to me that I should change the 5th argument which does some black magic bit shifting but as I'm not sure how this works and how to change it. 在我看来,我应该更改第5个参数,该参数进行了一些黑魔术转换,但由于我不确定这是如何工作的以及如何更改它。 Thanks 谢谢

The 4th and 5th parameters are minDB and maxDB, specified as in integer in 16.16 fixed point format. 第4和第5个参数是minDB和maxDB,以16.16定点格式以整数形式指定。 I think the dB here is meant to be dB relative to digital full scale - meaning that 0 dBFS is the max and the min is a negative value. 我认为这里的dB相对于数字满量程是dB-意味着0 dBFS是最大值,而min是负值。 At the very least, your parameters seem to be reversed and the sign of the positive value is wrong. 至少,您的参数似乎颠倒了,正值的符号是错误的。

The black magic as you call it is specifying a value in the 16.16 fixed point format. 您所说的黑魔法正在以16.16定点格式指定一个值。 See https://en.wikipedia.org/wiki/Q_(number_format) . 请参阅https://en.wikipedia.org/wiki/Q_(number_format)

It is setting the maxDB to 40.5. 它将maxDB设置为40.5。 The 40 coming from bitshifting the 40 up into the integer portion and the 0.5 coming from the 32768. A much more intuitive way of doing this is using the following method: 40来自将40向上移位到整数部分,而0.5来自32768。更直观的方法是使用以下方法:

Multiply the floating point value by 2^n where n is the number of fractional bits (xx.16) and then round the result. 将浮点值乘以2 ^ n,其中n是小数位数(xx.16),然后将结果取整。

int fixedPtVal = round(40.5 * (1<<16)); 

Back to the issue of what to choose for minDB and maxDB. 回到为minDB和maxDB选择什么的问题。 I couldn't really find any documentation on this but I think you would want to do something like: 我真的找不到关于此的任何文档,但我认为您想做类似的事情:

minDB = round(-40.5 * (1<<16));
maxDB = 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM