0
A
回答
0
看來,改變音量增益是不可能在飛行時AudioQueue運行,一些如何能夠增加麥克風增益緩衝器,張貼代碼,
void AQRecorder::setGain(void *data, int bytes, float gain){
SInt16 *editBuffer = (SInt16 *)data;
// loop over every packet
for (int nb = 0; nb < (bytes/2); nb++) {
// we check if the gain has been modified to save resoures
if (gain != 0) {
// we need more accuracy in our calculation so we calculate with doubles
double gainSample = ((double)editBuffer[nb])/32767.0;
/*
at this point we multiply with our gain factor
we dont make a addition to prevent generation of sound where no sound is.
no noise
0*10=0
noise if zero
0+10=10
*/
gainSample *= gain;
/**
our signal range cant be higher or lesser -1.0/1.0
we prevent that the signal got outside our range
*/
gainSample = (gainSample < -1.0) ? -1.0 : (gainSample > 1.0) ? 1.0 : gainSample;
/*
This thing here is a little helper to shape our incoming wave.
The sound gets pretty warm and better and the noise is reduced a lot.
Feel free to outcomment this line and here again.
You can see here what happens here http://silentmatt.com/javascript-function-plotter/
Copy this to the command line and hit enter: plot y=(1.5*x)-0.5*x*x*x
*/
gainSample = (1.5 * gainSample) - 0.5 * gainSample * gainSample * gainSample;
// multiply the new signal back to short
gainSample = gainSample * 32767.0;
// write calculate sample back to the buffer
editBuffer[nb] = (SInt16)gainSample;
}
}
}
記住此功能只應叫當有一個增益變化,否則保存CPU資源..
0
首先,問你的隊列其kAudioQueueProperty_CurrentDevice
,這是它的讀取設備的標識字符串。
接下來,您需要打開該設備。這是比它應該做的更多的工作,因爲Core Audio的設計人員通過通用的「GetProperty」和「SetProperty」功能相信所有事情都做得很好。這裏所說:
- 創建包含一個指向包含設備標識符和一個指向您希望
AudioDeviceID
變量的變量的AudioValueTranslation
結構。 - 使用
AudioHardwareGetProperty
或未被棄用,但更通用的AudioObjectGetProperty
得到kAudioHardwarePropertyDeviceForUID
,將指針傳遞給結構。 HAL將查找設備,並通過放置在結構中的指針將其返回給您。
如果這沒有返回錯誤,您現在有一個設備。
最後一步是設置其增益。我認爲這是顯示爲kAudioDevicePropertyVolumeScalar
上的輸入範圍,但我不是100%確定。無論如何,你會修補AudioDeviceSetProperty
和/或AudioObjectSetProperty
,直到找到合適的組合。
相關問題
- 1. 如何使用speex編解碼器的功能控制音頻回聲並降低話筒增益水平?
- 2. Rpart改進得分與信息增益
- 3. 編碼隨機1bit增益/損失
- 4. c#aforge模擬攝像頭ISP RGB增益寄存器更改
- 5. 的Django 1.9 - 更新或創建,增加收益/編輯ID
- 6. android audiomanager更改收益
- 7. 權限更改在OSX
- 8. 以最大增益順序跳轉 - 動態編程
- 9. Weka使用增益比和信息增益(ID3&C4.5(J48))
- 10. 網絡音頻API增益
- 11. C++/CLI性能增益
- 12. 聲音平底鍋增益?
- 13. 信息增益的負值
- 14. 增益蟒蛇y軸值
- 15. 性能增益屬性
- 16. 更改超編程
- 17. 十進制收益增加數在MySQL
- 18. 在OpenAL中發現最大增益
- 19. 更改目標C中音頻數據的增益會導致波形混亂
- 20. ALSA - 使用alsa api(linux)更改c代碼中的麥克風增益
- 21. 如何更改相機參數(自動曝光,快門速度,增益)?
- 22. 如何在Mac OSX上更改mysql $ PATH?
- 23. 通過Python在OSX中更改ActiveApplication
- 24. mysql增量更改
- 25. 以編程方式更改ASP.NET會話超時
- 26. 如何以編程方式更改對話框背景顏色?
- 27. 更改登錄會話編程方式使用目標C
- 28. Android:編程式更改手機設置並致電話丟失
- 29. 以編程方式更改會話超時
- 30. Android - 更改EditTextPreference對話框的正向按鈕文本編程
,非常感謝,我會試一試 – Amitg2k12 2013-02-28 03:47:54
我試過了,但我不能AudioObjectHasProperty總是返回麥克風錯誤,此外,我需要做它當AudioQueue運行:(,有一些解決方法張貼在這裏... – Amitg2k12 2013-03-01 03:09:41