에서 프로그래밍 방식으로 확보,변경 마이크, 내가 마이크 게인을 변경하려면 버퍼를 캡처하는 AudioQueue를 사용하지만, 어떤 포인터를 받고 있지 않다 나는 마이크 게인을 변경했다 내 응용 프로그램에서</p> <p>OSX 10.8 오전 OSX
애플 HAL 문서도하지만,
에서 프로그래밍 방식으로 확보,변경 마이크, 내가 마이크 게인을 변경하려면 버퍼를 캡처하는 AudioQueue를 사용하지만, 어떤 포인터를 받고 있지 않다 나는 마이크 게인을 변경했다 내 응용 프로그램에서</p> <p>OSX 10.8 오전 OSX
애플 HAL 문서도하지만,
는 볼륨 이득을 변경하면 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 리소스를 절약하십시오.
첫째, 아무것도 얻을 것이 읽는 것 장치의 식별자 문자열의 kAudioQueueProperty_CurrentDevice
, 대한 대기열을 요구하지 않았다.
다음으로 해당 장치를 열어야합니다. Core Audio의 설계자는 일반적인 "GetProperty"및 "SetProperty"기능을 통해 모든 것을 수행하는 것을 믿기 때문에 이것이해야 할 일보다 많은 작업입니다. 여기 간다 :
AudioDeviceID
을하고자하는 변수에 대한 포인터가 포함 된 변수에 대한 포인터를 포함하는 AudioValueTranslation
구조를 만듭니다.AudioHardwareGetProperty
또는 더 이상 사용되지 않지만 더 일반적인 AudioObjectGetProperty
을 사용하여 kAudioHardwarePropertyDeviceForUID
을 가져 와서 포인터를 구조체에 전달합니다. HAL은 장치를 검색하여 구조에 넣은 포인터를 통해 장치를 반환합니다.오류가 반환되지 않으면 이제 장치가 있습니다.
마지막 단계는 이득을 설정하는 것입니다. I 이것은 입력 범위에 kAudioDevicePropertyVolumeScalar
으로 표시되지만 100 % 확신 할 수는 없습니다. 어쨌든 올바른 조합을 찾을 때까지 AudioDeviceSetProperty
및/또는 AudioObjectSetProperty
으로 조정할 것입니다.
고마워요. 시도해 보겠습니다. – Amitg2k12
시도했지만, AudioObjectHasProperty는 항상 마이크에 대한 오류를 반환합니다. AudioQueue가 실행 중일 때 :(여기에 몇 가지 해결 방법이 있습니다 ... – Amitg2k12